- Home /
How to set a string to a UI text?
I got a c#-script that should change the text in a canvas to a string. But i cant get it to work. I always get an error which says:
CS0029: Cannot implicitly convert type UnityEngine.UI.Text' to
string'
And this is my Script:
using UnityEngine; using System; using UnityEngine.UI;
public class ToolbarTip : MonoBehaviour { public int CurrentSlot; public Text Text; public GameObject textgameobject; void Start() { Text.text = textgameobject.GetComponent(); Text.text = "SomeText"; }
Comment
Answer by RLin · Jul 23, 2015 at 10:17 PM
In the start function where you retrieve your text gameobject, remove the ".text" at the end.
Your answer
![](https://koobas.hobune.stream/wayback/20220611232715im_/https://answers.unity.com/themes/thub/images/avi.jpg)