- Home /
Cannot dynamically change text in build
I have created a scene in which I dynamically change the text of a GUItext gameObject. Inside Unity it works fine, but in PC or Web builds it just ignores the command and doesn't continue with the rest of the commands in the specific function (the game doesn't crash)
I just change the text using:
dataOutput.guiText.text = "name"; // dataOutput is a Gameobject which a GUItext in the scene is connected to.
The font is the default "Arial".
The script is places on an empty gameObject
What could be the reason?
just FWIW it's unbelievably simpler to just get 2DTooljit and use the dynamic text that its totally built-in
notice my long comment just under the question.....
http://answers.unity3d.com/questions/384623/setting-font-size-according-to-screen-dpi.html
Answer by avivshaviv · Sep 11, 2013 at 02:10 PM
I made a lot of debugging and I found the source of the problem and bypassed it, but it is still a bug in Unity. When I used Public GameObject variables in C# and connected gameObjects from the scene to the variable slots in the script, the game didn't work well outside of Unity (via build for PC or Web). I disconnected the gameObject in the scene and referenced them by using GameObject.find();
Now it works fine... strange.
Thanks anyway Fattie :)
Your answer
