Quantcast
Channel: Questions in topic: "error"
Viewing all articles
Browse latest Browse all 7934

error when trying to change TextMesh.text through script

$
0
0
Hey guys, I have have a problem I can't understand. In my scene there is a 3D Text object with a script assigned to it. The script is a simple MonoBehaviour script and looks like this: using UnityEngine; using System.Collections; public class DisplayHighscore : MonoBehaviour { // Use this for initialization void Start() { GetComponent(TextMesh).text = "hi"; } } But I get these three error messages and I have no idea why. > error CS0119: Expression denotes a `type', where a `variable', `value' or `method group' was expected>> error CS1502: The best overloaded method match for `UnityEngine.Component.GetComponent(System.Type)' has some invalid arguments>> error CS1503: Argument `#1' cannot convert `object' expression to type `System.Type' I hope one you knows what's going wrong here... btw: when I do it like this I don't get an error, but nothing happens: TextMesh text = (TextMesh)GetComponent(typeof(TextMesh)); text.text = "hi";

Viewing all articles
Browse latest Browse all 7934

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>