Search Unity

  1. Unity 2019.1 is now released.
    Dismiss Notice

Not loading scene

Discussion in 'Editor & General Support' started by harryrankin6, May 17, 2019.

  1. harryrankin6

    harryrankin6

    Joined:
    Apr 3, 2019
    Posts:
    7
    So I'm making a game and I'm making the UI's and when I want it to load a scene like the back button it doesent load. I can show you the script if it helps.
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.SceneManagement;
    5.  
    6. public class SceneTeleport : MonoBehaviour
    7. {
    8.     void Update()
    9.     {
    10.         if (Input.GetMouseButtonDown(0))
    11.         {
    12.             SceneManager.LoadScene(1);
    13.         }
    14.     }
    15.  
    16.     public void SceneLoad(int index)
    17.     {
    18.         SceneManager.LoadScene(index);
    19.     }
    20. }
    21.  
    and the unity version is 2019.3.0a2.

    I have a video of it.
     
  2. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    4,330
    Please show the code in your Button click event.
     
  3. harryrankin6

    harryrankin6

    Joined:
    Apr 3, 2019
    Posts:
    7
  4. kdgalla

    kdgalla

    Joined:
    Mar 15, 2013
    Posts:
    1,155
    Have you added all of your scenes in the build settings?
     
  5. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    4,330
    Do you have scene with index = 2? Also, you probably want to remove the code in Update. It will quickly go to scene 1 if there is any mouse click.
     
  6. harryrankin6

    harryrankin6

    Joined:
    Apr 3, 2019
    Posts:
    7
  7. harryrankin6

    harryrankin6

    Joined:
    Apr 3, 2019
    Posts:
    7
    I already have done that
     
  8. harryrankin6

    harryrankin6

    Joined:
    Apr 3, 2019
    Posts:
    7
    I fixed it
     
  9. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    4,330
    It's generally considered proper forum etiquette to share HOW you fixed it so others may benefit.