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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Issues With SceneManager

Discussion in 'Scripting' started by torombolo89, Dec 13, 2015.

  1. torombolo89

    torombolo89

    Joined:
    Aug 25, 2015
    Posts:
    30
    Hello im trying to figure it out but im not seeing any examples...


    Im trying to find the appropiate way to do :
    Application.LoadLevel(Application.loadedLevel)
    in 5.3 Scene Manager but i cant find it...

    When i do SceneManager.LoadScene("TheSameScene") unity Stops Responding...

    Thank you.
     
  2. staraffinity

    staraffinity

    Joined:
    Sep 16, 2014
    Posts:
    7
    I'm also having trouble – getting a simple scene switching script to parse without error. I've tried to follow the scripting reference here: http://docs.unity3d.com/ScriptReference/SceneManagement.SceneManager.LoadScene.html

    The thing is, I'm not sure where to put that line of code as in the example (yes, I'm new to scripting). Could someone provide a simple example script or info on how to implement the (new since Unity 5.3.0 if I understand correctly) SceneManager?
     
  3. mikeymike

    mikeymike

    Joined:
    Oct 21, 2014
    Posts:
    35
    make sure your using the namespace at the top of your code
    Code (csharp):
    1.  using UnityEngine.SceneManagement;
     
  4. LeftyRighty

    LeftyRighty

    Joined:
    Nov 2, 2012
    Posts:
    5,148
  5. staraffinity

    staraffinity

    Joined:
    Sep 16, 2014
    Posts:
    7
    Thanks guys – this worked for me:

    Code (csharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using UnityEngine.SceneManagement;
    4.  
    5. public class SceneSwitcher : MonoBehaviour
    6. {
    7. public void LoadScene(int SampleScene)
    8. {
    9. SceneManager.LoadScene(SampleScene);
    10. }
    11. }
     
  6. Prodigga

    Prodigga

    Joined:
    Apr 13, 2011
    Posts:
    1,121
    For those wondering; The SceneManager equivelent of this:

    Code (CSharp):
    1. Application.LoadLevel(Application.loadedLevel)
    would be this:

    Code (CSharp):
    1. SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
     
    staraffinity and Kiwasi like this.