Search Unity

New level (scene) loads automatically. Help!

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

  1. SirMarley

    SirMarley

    Joined:
    Jul 26, 2014
    Posts:
    115
    Hi guys...

    I have 2 issues here, to see if you can help me:

    1) I have a languaje selection scene with 3 flags as GUI buttons, and, when you click on any of them, you go to the main screen with the title.

    The issue is that it does not wait for the button to be pressed, and goes directly to this new scene.

    I have if (GUI.button, etc) { Application.LoadLevel("MainScreen");

    How can I fix this?

    2) In the Main Screen I have an animation with the title and some other graphics and, depending on the lang selected, it will say "Press Anywhere to Continue"... how can I make this message, after the whole animation is played?

    Thanks a lot!!!
     
  2. Sykoo

    Sykoo

    Joined:
    Jul 25, 2014
    Posts:
    1,394
    1) The GUI Buttons are GUI Textures I'd assume as they're flags?
    If they are, use this:
    Code (CSharp):
    1. void Update() {
    2.     if(textureRect.Contains(Input.MousePosition)){
    3.         if(Input.GetMouseButtonDown(0))
    4.             DoThis();
    5.     }
    6. }
    The problem is that GUITextures aren't automatically "detecting" their own sizes/areas, so you have to specify that you click on the textures instead of the screen.

    2)
    Code (JavaScript):
    1. var myText = "Press anywhere to continue!";
    2.  
    3. ...I assume you have some codes here regarding the animation...
    4.  
    5. yield WaitForSeconds(3) //Use the length of your animation
    6.  
    7. myText.enabled = true;
    8.  
    9.  
    10. function OnGUI(){
    11. if(myText == true){
    12.       GUI.Label(Rect(20,20,100,20),myText.ToString());
    13.      }
    14. }