Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

loading scene

Discussion in 'Scripting' started by cosmoplay, Apr 26, 2015.

  1. cosmoplay

    cosmoplay

    Joined:
    Apr 26, 2015
    Posts:
    2
    created a scene from "carrying", after the scene "Menu". The menu has audio when I click play, it goes to the loading screen and then after 4 seconds he enters the scene of the game "level 1". So far so good, is working as I wanted, but when I click "Esc" to enter the pause menu, and Cliko the main menu, it returns to the menu, but the menu is not audio and more if I click again "game" it goes to the loading screen, but does not load the "level 1"

    Can someone please help me?
    all used herein escripts:

    Pause Menu:
    [Code = JavaScript] var mainMenuSceneName: String;
    var pauseMenuFont: Source;
    private var pauseEnabled = false;

    function start () {
    pauseEnabled = false;
    Time.timeScale = 1;
    AudioListener.volume = 1;
    Cursor.visible = false;
    }

    Update () function {

    // Check if the pause button (Escape key) is pressed
    if (Input.GetKeyDown ("escape")) {

    // Check if the game is already paused
    if (pauseEnabled == true) {
    // Resume the game
    pauseEnabled = false;
    Time.timeScale = 1;
    AudioListener.volume = 1;
    Cursor.visible = false;
    }

    // Else if game is not paused then pause
    else if (pauseEnabled == false) {
    pauseEnabled = true;
    AudioListener.volume = 0;
    Time.timeScale = 0;
    Cursor.visible = true;
    }
    }
    }

    var private showGraphicsDropDown = false;

    OnGUI function () {

    GUI.skin.box.font = pauseMenuFont;
    GUI.skin.button.font = pauseMenuFont;

    if (pauseEnabled == true) {

    // Makes a bottom box
    GUI.Box (Rect (Screen.Width / 2-100, Screen.Height / 2-100250200), "Pause");

    // Do the Main Menu button
    if (GUI.Button (Rect (Screen.Width / 2-100, Screen.Height / 2 - 50,250,50), "Main Menu")) {
    Application.LoadLevelAsync (mainMenuSceneName);
    }

    // Change Quality button graphics do
    if (GUI.Button (Rect (Screen.Width / 2-100, Screen.Height / 2, 250.50), "Graphics Quality")) {

    if (showGraphicsDropDown == false) {
    showGraphicsDropDown = true;
    }
    else {
    showGraphicsDropDown = false;
    }
    }

    // Create the buttons of graphics settings, these will not appear automatically, they will be called when
    // The user clicks the "Change Quality Graphic" button, and then disappear when they click
    // In it again ....
    if (showGraphicsDropDown == true) {
    if (GUI.Button (Rect (Screen.Width / 2 + 150, Screen.Height / 2, 250.50), "Very Bad")) {
    QualitySettings.currentLevel = QualityLevel.Fastest;
    }
    if (GUI.Button (Rect (Screen.Width / 2 + 150, Screen.Height / 2 + 50,250,50), "Bad")) {
    QualitySettings.currentLevel = QualityLevel.Fast;
    }
    if (GUI.Button (Rect (Screen.Width / 2 + 150, Screen.Height / 2 + 100,250,50), "Simple")) {
    QualitySettings.currentLevel = QualityLevel.Simple;
    }
    if (GUI.Button (Rect (Screen.Width / 2 + 150, Screen.Height / 2 + 150,250,50), "Good")) {
    QualitySettings.currentLevel = QualityLevel.Good;
    }
    if (GUI.Button (Rect (Screen.Width / 2 + 150, Screen.Height / 2 + 200,250,50), "very good")) {
    QualitySettings.currentLevel = QualityLevel.Beautiful;
    }
    if (GUI.Button (Rect (Screen.Width / 2 + 150, Screen.Height / 2 + 250,250,50), "Fantastic")) {
    QualitySettings.currentLevel = QualityLevel.Fantastic;
    }

    if (Input.GetKeyDown ("escape")) {
    showGraphicsDropDown = false;
    }
    }

    // Make out game button
    if (GUI.Button (Rect (Screen.Width / 2-100, Screen.Height / 2 + 50,250,50), "Quit Game")) {
    Application.Quit ();
    }
    }
    } [/ Code]




    _________________________________________________

    Load Level:
    [Code = JavaScript] strict #Pragma

    function start () {

    WaitForSeconds income (4);

    Application.LoadLevelAsync ("the dilma");

    } [/ Code]


    ___________________________________________________


    Menu play button:
    [Code = JavaScript] strict #Pragma

    var highlight: Light;

    OnMouseEnter () function {

    spotLight.color = Color.blue;

    }

    OnMouseExit () function {

    spotLight.color = Color.White;

    }

    OnMouseDown () function {

    Application.LoadLevel ("Loading");

    }
    [/ Code]



    ______________________________________________________

    Note: translated by Google Translate Portuguese in Brazil> English