Search Unity

GUItext & TextMesh working perfectly in editor but not working in Build and Run.

Discussion in 'Immediate Mode GUI (IMGUI)' started by HoangPh, Jun 3, 2014.

  1. HoangPh

    HoangPh

    Joined:
    Apr 25, 2014
    Posts:
    18
    Im got an issue here is that i creat 2 object are text Mesh one for Score and another for HighestScore. i controll them with a GameManager script attached to _GM objects.
    Here is the script
    public TextMesh highestScore;
    public TextMesh score;

    void Awake ()
    {
    highestScore.text = "Highest Score:" + PlayerPrefs.GetInt("HighestScore");
    score.text = "Score:" + points;
    }
    which are works prety well in the editor but when i build the game. the Text just showed Hello world which are default. I have remembered to attach both the text mesh to the script but it dont work after build and run. please help me and thanks for all the help.
    BTW. ITS HAPPEN THE SAME WITH GUItext. =((
     
  2. _met44

    _met44

    Joined:
    Jun 1, 2013
    Posts:
    633
    Hi,

    Did you fill in some default value ?

    Try this:
    Code (csharp):
    1. highestScore.text = "Highest Score:" + PlayerPrefs.GetInt("HighestScore", 0);
    Remember you have a log file for your debug builds, you can look into the project's folder and read what that file says when you have bugs that differ from what you see in the editor.

    In your case you probably have some value set for the editor playerpref but nothing yet for the build so the script just crashes there except that you don't see it thanks to unity handling the error discretly for you.
     
    HoangPh likes this.
  3. HoangPh

    HoangPh

    Joined:
    Apr 25, 2014
    Posts:
    18
    im sorry but i edit the _GM's tag is EditorOnly so its doesnt work. Sorry for wasting your time =P