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

Move to another scene

Discussion in 'Scripting' started by Morseton, Feb 3, 2016.

Thread Status:
Not open for further replies.
  1. Morseton

    Morseton

    Joined:
    Jan 15, 2016
    Posts:
    90
    I'm making an intro scene for my game, and when the intro is done, I want to move to another scene. I've searched around for ways to do this and all I find is obsolete functions(Application.loadlevel).

    It seems that it got replaced with sceneManager stuff but I don't get how that works..
    Can anyone help me out? I need to go from the intro scene to the actual game scene!

    Thanks
     
  2. Deleted User

    Deleted User

    Guest

    Code (CSharp):
    1. UnityEngine.SceneManagement.SceneManager.LoadScene(0);
    But you can just enter your scene string or int in the parameter for LoadScene as you normally would with the old Application.LoadLevel method.

    EDIT:

    Code (CSharp):
    1. using UnityEngine.SceneManagement;
    2.  
    You can add that to the top and you can access SceneManager like normal:

    Code (CSharp):
    1. SceneManager.LoadScene(0);
    Either way it does the same thing.
     
    Lord-Tea likes this.
  3. Morseton

    Morseton

    Joined:
    Jan 15, 2016
    Posts:
    90
    by the way, when I load a new scene, the one that I'm currently in disapears?
     
  4. Deleted User

    Deleted User

    Guest

    No. But when you return to the scene, any changes that were made while the player was playing in that scene will be completely reversed. When loading a scene in a game, you are loading everything the exact way that you had it setup. In order to keep changes you need to learn about saving and loading game data as well as singleton objects.

    Either way don't worry about that for now. You can go back and forth between scenes as much as you want.
     
  5. Morseton

    Morseton

    Joined:
    Jan 15, 2016
    Posts:
    90
    I'm just worried about lagging if I load another scene, just wondering if the intro scene stuff will still occupy memory

    mhmm i can't seem to have any SceneManager.LoadScene option :s

    I added using UnityEngine.SceneManagement; like you said but it doesn't appear.. only scenemanager.instantiate
     
  6. Deleted User

    Deleted User

    Guest

    Nope. Scenes default behavior doesn't allow them to share memory. Once you load a new scene, the data from the previous scene is offloaded from memory. There won't be any lag at all.
     
  7. Morseton

    Morseton

    Joined:
    Jan 15, 2016
    Posts:
    90
    Ok, the scenemanager.load wasn't appearing but I used the first one you said:
    UnityEngine.SceneManagement.SceneManager.LoadScene(0);

    now it appears, thanks!

    1 thing:

    UnityEngine.SceneManagement.SceneManager.LoadScene("scene");

    isn't working

    getting this error:
    scene "scene" (-1) couldn't be loaded because it has not been added to the build settings
     
  8. Deleted User

    Deleted User

    Guest

    Go to File > Build Settings and simply drag and drop your scenes into the list.
     
  9. Morseton

    Morseton

    Joined:
    Jan 15, 2016
    Posts:
    90
    thanks!
     
  10. Morseton

    Morseton

    Joined:
    Jan 15, 2016
    Posts:
    90
    I cam across something strange.
    When I load the game scene, some materials aren't working. but If I play that game scene directly as the first scene, the material is working perfectly. What's causing this?

    The material gets completely black when I load the scene
     
  11. FormalSnake

    FormalSnake

    Joined:
    Oct 26, 2019
    Posts:
    12
    how do i go back to my scene?

    i clicked another scene by accident.
     
  12. dylanmandal

    dylanmandal

    Joined:
    Dec 3, 2020
    Posts:
    1
    to go back to your scene you simply just drag it into the hiearchy from your prefabs
     
  13. Deleted User

    Deleted User

    Guest

    I have the same question and it seems a little complicated than I first thought
     
  14. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,817
    Please don't post vague replies to 6-year-old threads. Start your own post, it's FREE!

    Remember, nobody here can read your mind. There are MANY questions in this thread.

    Why not actually say what your question is, and do so in a NEW POST.

    When you post, here is how to report your problem productively in the Unity3D forums:

    http://plbm.com/?p=220
     
    MelvMay likes this.
  15. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,563
    Agreed. Let's lock this thread because I'd suggest it's outlived its usefulness.
     
Thread Status:
Not open for further replies.