Programmier Fehler kann mir wer helfen?
if (other.tag == "Coin")
{
coinCounter++;
Destroy (other.gameObject);
scoreText = "Score: " + coinCounter;
Debug.Log ("Score: " + coinCounter);
}
Das Ist mein Code und irgendetwas ist daran nicht richtig den ich kriege immer diesen error Assets\scripts\Player.cs(26,21): error CS0029: Cannot implicitly convert type ‘string’ to ‘UnityEngine.UI.Text’ kann mir wer helfen?
Hello.
The error states that the assignment
can’t work like that. I’ve never done anything with Unity, but probably there’s a method to set texts, or it’s ideally an object, then there’s probably gonna be the field “Text” you can set.
Try it like that.
and if that doesn’t work, then so:
Good luck. 👍
not quite standing
Text’ does not contain a definition for ‘SetText’ and no accessible extension method ‘SetText’ accepting a first argument of type ‘Text’ could be found (are you missing a using directive or an assembly reference?)
Like I said, I never did anything with Unity. I can only make guesses. But it’s nice that the other one worked! 👍
but that’s what I mean
scoreText.text = “Score: ” + coinCounter;
DANKE
and if you want to do it correctly, you will not only flip a variable with a numerical value into the text attribute, but you will convert it properly into a string.
Make sure this variable is set in the Unity Inspector: