Search Unity

LoadLevel not working. HELP, PLEASE!!!!

Discussion in 'Scripting' started by SirMarley, Jul 28, 2014.

  1. SirMarley

    SirMarley

    Joined:
    Jul 26, 2014
    Posts:
    115
    Guys...

    What is wrong with this piece of code?

    It does not wait for the button to be pressed and loads and plays another scene after 1 second

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class LangSel : MonoBehaviour {
    5.  
    6.     public Texture backgroundTexture;
    7.     public GUIStyle ENGFlag;
    8.     public GUIStyle SPAFlag;
    9.     public GUIStyle CHIFlag;
    10.  
    11.     void OnGUI(){
    12.         GUI.DrawTexture(new Rect(0,0,Screen.width,Screen.height),backgroundTexture);
    13.  
    14.         if (GUI.Button (new Rect(Screen.width * .05f, Screen.height * .5f, Screen.width * .25f, Screen.height * .2f), "", ENGFlag));{
    15.             PlayerPrefs.SetInt("EngSpaChi", 1);
    16.             Application.LoadLevel("FirstScreen");
    17.         }
    18.         if (GUI.Button (new Rect(Screen.width * .37f, Screen.height * .5f, Screen.width * .25f, Screen.height * .2f), "", SPAFlag));{
    19.             PlayerPrefs.SetInt("EngSpaChi", 2);
    20.             Application.LoadLevel("FirstScreen");
    21.         }
    22.         if (GUI.Button (new Rect(Screen.width * .7f, Screen.height * .5f, Screen.width * .25f, Screen.height * .2f), "", CHIFlag));{
    23.             PlayerPrefs.SetInt("EngSpaChi", 3);
    24.             Application.LoadLevel("FirstScreen");
    25.         }
    26.     }
    27.  
    28. }
    29.  
     
  2. Patico

    Patico

    Joined:
    May 21, 2013
    Posts:
    886
    Remove comma ; at the end of lines 14, 18 and 22
     
    SirMarley likes this.
  3. SirMarley

    SirMarley

    Joined:
    Jul 26, 2014
    Posts:
    115
    Thanks!!!!