- Home /
GUI & GUI Text Disappear When Publishing
In the game I'm working on I have a simple GUI button to Start/exit the game, as well as a script that uses GUI Text to create a timer (it's a timed level). Both work accordingly when the game is played within Unity, however upon publishing, the timer fails to initiate and just displays "5:00" without changing, and the GUI button isn't present at all. I have cleaned out the build settings but am still having this issue. Any ideas what could be causing this? I'm at a loss.
Answer by Ray-Pendergraph · Apr 22, 2010 at 12:52 PM
You said the timer fails to initiate. One thing that can act differently in deployed mode (particularly if debugging is turned off) is that threading and coroutine situations may create differing results in deploy vs development mode. This behavior is not specific to Unity or C# and I attribute it here to the fact that the Unity logging process is expensive enough to cause significant differences when enabled/disabled. Every time a log event is generated in Unity the stack is unwound and it does add up.
I would check your assumptions around the updating or initialization of the timer. Where is it initialized? Where is it updated? Maybe you could post the relevant code?
Answer by martijn v · May 27, 2010 at 02:46 PM
I have a simular problem with my GUI after i published the scene. I created 2 GUI texts in the upper right corner. They are still nemed GUI text. In the script i change the text to score and the other to level. When i click play in Unity it works and when i publish it it says 2 times GUI text.
My quess is that it's in the function OnGUI() that i use.
here is the code i use
private static var Score = 0;
private static var Level = 1;
function OnGUI () { gameObject.Find ("guiLevel").guiText.text = "Level : " + Level;
guiText.guiText.text = "Score : "+Score;
GUI.contentColor = Color.black;
}
$$anonymous$$artijn, you could try rena$$anonymous$$g the GUItext within Unity rather than via a script, that will at least ensure your Score counter is not labled GUItext upon publishing. However if the script is not causing the names to change, its unlikely it will update the score either. The only way I've found to resolve this problem is to remake the entire project. It seems like something causes Unity to not deploy the script upon publishing, though it's likely not an issue with the script itself.
Answer by Stephanie · May 28, 2010 at 06:46 AM
Only solution I've discovered is to rebuild the project. It's often not an issue with the script itself.
Are you shure there isn't any other way of fixing it because then i have to rebuild a hole lot of work.
thats not what he means. he means delete the published game, remove all scenes from build settings, add them again, and then build
Answer by khalil · Jun 09, 2010 at 10:25 PM
Maybe you could turn all your GUI elements to independent (or parented) "Game Objects" and attach your scrips these "game objects", rather than just having "scripts" run the show. This should resolve your memory leak when you build the game.
Answer by x4000 · Oct 06, 2010 at 04:35 PM
One thing I've found is that any assets that aren't specifically included in any scene in your project at build time won't be in your assets folder. So it could be that if you don't use the textures or similar anywhere else in your scene except programmatically instantiating it, that it's excluding the texture assets from your actual published version.
In that case, the solution is simple: just add a reference to the missing assets somewhere in your scene. That may or may not be what's going on here, but I've run into it before and thought it's worth a shot.
Your answer
Follow this Question
Related Questions
Help with making a triggered gui message 1 Answer
GUI Menu Display Help 2 Answers
Force Unity UI element to refresh/update? 4 Answers
GUIText Problem With MENU 1 Answer
Gui Button Solid 2 Answers