Hey guys. So I have a game object with a text component, and I have UI Text canvas on the hierarchy. I want that every time an object is clicked, the text component on the game object will be copied to the UI Text on the canvas. I’m getting two errors:
Assets/Scripts/ModelProperties.cs(14,17): error CS0029: Cannot implicitly convert type UnityEngine.GameObject[ ]' to UnityEngine.UI.Text’
Assets/Scripts/ModelProperties.cs(15,24): error CS0428: Cannot convert method group GetComponent' to non-delegate type string’. Consider using parentheses to invoke the method
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class ModelProperties : MonoBehaviour {
public Text UIText;
void OnMouseDown ()
{
UIText = GameObject.FindGameObjectsWithTag("Text");
UIText.text = gameObject.GetComponent<Text>;
}
}