- Home /
Unknown Identifier: 'TextObj'.
So, I'm really new to programming with unity. I'm trying to get my head around the apis and such. I thought this would be a little easier since i have a lot of programming experience with javascript already So what I'm doing is that i have created a text object in the center of my screen named dot (or that is at least what it says in the Hierarchy). What i want to do is that when i click with my left mouse button, it should briefly change the color of the text to something else. This is the code that I'll use on the "dot" object:
function Start() {
var TextObj = GetComponent.<TextMesh>();
}
function Update() {
TextObj.color = Color.red;
}
When i go back to unity, it says in the console: "Unknown identifier: 'TextObj'." But why does it do that when I already have defined the variable "TextObj"? Btw, this is only a part of the script.
Answer by ShadyChirp · Dec 03, 2017 at 06:33 PM
I found the solution by myself:
function Start() {
}
function Update() {
if (Input.GetMouseButton(0)) {
GetComponent(TextMesh).color = Color.yellow;
} else if (Input.GetKeyUp("mouse 0")) {
GetComponent(TextMesh).color = Color.white;
}
}
-Shady
Your answer
Follow this Question
Related Questions
What are Asserts for? 1 Answer
Error importing asset from google poly api in android build unity 0 Answers
Unity 5 API Updater Keeps Failing 4 Answers
android player error 0 Answers