Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Play button working on editor but not built game?

Discussion in 'Editor & General Support' started by Tezelian, Apr 11, 2014.

  1. Tezelian

    Tezelian

    Joined:
    Oct 22, 2013
    Posts:
    256
    My play button which is a GUITexture in my main menu works on editor and directs me to the next scene, however the same button does not work once the game is built? Why can this be happening to me!?

    Please I need help

    Thanks

    This is the code for the button


    Code (csharp):
    1. AudioListener.pause = false;
    2. //do not pause audio
    3.  
    4. var levelToLoad : String;
    5. var QuitButton : boolean = false;
    6. var music : AudioClip;
    7. var a = true;
    8.  
    9. var greenplay : GUITexture;
    10.  
    11.  
    12. function OnMouseDown() {
    13.  
    14.  
    15. if (a == true)
    16. {
    17. audio.PlayOneShot(music);
    18. Application.LoadLevel("Game");
    19.  
    20. }
    21.  
    22.  
    23. }
    24.  
    25. function OnMouseEnter() {
    26.  
    27. greenplay.enabled = true;
    28.  
    29. }
    30.  
    31.  
    32. function OnMouseExit() {
    33.  
    34. greenplay.enabled = false;
    35.  
    36. }
     
  2. DanielQuick

    DanielQuick

    Joined:
    Dec 31, 2010
    Posts:
    3,137
    What is your target platform?

    Does it give an error?
     
  3. Tezelian

    Tezelian

    Joined:
    Oct 22, 2013
    Posts:
    256
    hey thanks I solved it and the audio variable wasn't being used so I was getting a null reference error but I solved it now.