Help with simplyfying this line of code!

Hello, I’m relatively new to unity and the tutorial I’m following uses the line below to declare a variable

public TMP_Text tmpro => tmpro_ui != null ? tmpro_ui : tmpro_world;

The problem is I’m getting an error in unity saying:
error CS0173: Type of conditional expression cannot be determined because there is no implicit conversion between ‘TMPro.TextMeshProUGUI’ and ‘TMPro.TextMeshPro’

I assume that this is about the version of c# used in unity 2020. Is there a way to write the same line of code in different way? For example:

if (tmpro_ui != null)
    public TMP_Text tmpro = tmpro_ui; 
else 
    public TMP_Text tmpro = tmpro_world;

Sorry If this is dumb. If you can help me with transforming that line of code ti will be very very helpful. Thank you.

I believe the problem is not the version of Unity you are using but rather the assignment. TextMeshPro has both TextMeshProUGUI and TextMeshPro class, the error is telling you that you are trying to implicitly assign one class to a different one. TextMeshProUGUI is used when working with canvas elements. TextMeshPro is used for meshes in 3D world space I don’t know exactly what you want to do, but if you just want to set the text you can do as follows:


 public TMP_Text tmpro;
 if (tmpro_ui != null)
     tmpro.SetText(tmpro_ui.text); 
 else 
     tmpro.SetText(tmpro_world.text);