MissingComponentException: There is no ‘GUIText’ attached to the “Empty” game object, but a script is trying to access it.
You probably need to add a GUIText to the game object “Empty”. Or your script needs to check if the component is attached before using it.
Basic_Programming(JAVA).Main () (at Assets/Basic_Programming(JAVA).js:9)
Any ideas?
I did add it under my object - I mean, parented it (named ‘Empty’) and it still wont clear that error!
Both the script and a GUIText should be added to that GameObject, you can’t put them in two different objects.
GUIText is pretty outdated though, real GUI is the way to go.
simply write
//Add text when you click the mouse
//Warning, all code typed in browser, cannot guarantee that it works
var mytextlabel = "Hello";
function OnGUI () {
//Display some text
GUILayout.Label (mytextlabel);
}
function Update () {
if (Input.GetKey ("mouse 0")) {
//Add text to the label, \n is a line break
mytextlabel += "someone clicked the mouse\n";
}
}
The script on the wiki is a bit more advanced though.
If you want to see the log (Debug.Log calls) from a build (game), you can open the Player Log, click the “Open Player Log” button located at the top-right corner of the Console window (the one where you see all errors and such).