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

LoadScene ("MainMenu");--solved--

Discussion in 'Scripting' started by xpath, Dec 9, 2018.

  1. xpath

    xpath

    Joined:
    Dec 3, 2018
    Posts:
    20
    ---Solved--
    start(){
    Time.timeScale=1f;
    Screen.lockCursor=False;
    Cursor.visible=true;
    }
    ---Solved--

    Hello there,

    My English is not good, sorry.

    When my game character dies 3 times, I want to send it to the main menu.

    Code (CSharp):
    1. public void Update (){
    2.         if (raundenemy>= 3) {
    3.             Debug.Log ("WİNN");
    4.         PlayerPrefs.DeleteAll ();
    5.             SceneManager.LoadScene ("MainMenu");
    6.         }
    7. }
    I'm starting the game from the main page and I don't have any problems.
    When raundenemy 3 is going back to the main page but I can not click any button.

    I can do it if I want to direct it to different scenes.it works smoothly.

    Code (CSharp):
    1. SceneManager.LoadScene ("level4");

    Main camera in Main menu

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.SceneManagement;
    5. using UnityEngine.UI;
    6. public class lvlcagir : MonoBehaviour {
    7.  
    8.  
    9.     // Use this for initialization
    10.     public void lvl1 () {
    11.         SceneManager.LoadScene("level1");
    12.     }
    13.  
    14.     // Update is called once per frame
    15.     public void lvl2 () {
    16.         SceneManager.LoadScene("level2");
    17.     }
    18.     public void lvl3 () {
    19.         SceneManager.LoadScene("level3");
    20.     }
    21.     public void lvl4 () {
    22.         SceneManager.LoadScene("level4");
    23.     }
    24.     public void AnaMenu () {
    25.         SceneManager.LoadScene("MainMenu");
    26.     }
    27.     public void exit () {
    28.         Application.Quit();
    29.     }
    30.     public void AraMenu () {
    31.         SceneManager.LoadScene("searchmenu");
    32.     }
    33.     public void Randomlvl(){
    34.         int index = Random.Range (2, 5);
    35.         SceneManager.LoadScene (index);
    36.     }
    37. }

    thanks for the answers.
     
    Last edited: Dec 11, 2018
  2. fire7side

    fire7side

    Joined:
    Oct 15, 2012
    Posts:
    1,819
    When I can't click any buttons it usually because the event system didn't load. You should be able to see it in the hierarchy window. I don't know why it wouldn't load the second time, though, or if that's it.
     
  3. xpath

    xpath

    Joined:
    Dec 3, 2018
    Posts:
    20
    Loading event system. I can see the hierarchy window. Yes, the second time I try to install the problem. I don't see this problem when I write a different scene name.

    thanks for the answer.