Today: 15ish minutes to follow a tutorial, and an hour with the help of Herbie to try to unravel why I can't get the text to show up.
Lesson learned:
Do NOT attach GUI as a child or component to... everything else, because its position works differently than... everything else.
Forumer's post that helped me discover this mistake:
"Please do what I said and make the GUIText a separate object. It should
not be a child of the camera, it should not be a component on the
camera. It must be a totally separate independent object because it
uses viewport space, not world space. It works 100%
correctly: GameObject > Create Other > GUIText. Do not move it
away from the 0..1 range in x/y or it won't be visible."
Solution:
Created a separate script for GUI.
void OnGUI(){
gameObject.guiText.text = "Score:" + GM_Cs.theScore;
}
How position works: 0.5, 0.9 would be "upper middle of the screen".
noted for later use, changing something's position in script:
gameObject (or score.gameObject) .transform.position
No comments:
Post a Comment