Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by jcrosby · Dec 29, 2016 at 06:31 PM · scene-switchingsplash-screenasynchronous

Issues With Scene Transition

I am trying to switch from a main menu scene to a game scene. I have a splash screen setup to use during the transition however I run into problems. I have tried it different ways with different problems. First I tried this:

 public void MountainCampButton() {
     gameObject.SetActive(false);
 
     splashScreen.GetComponent<SplashScreen>().SetLevel("Mountain Camp");
     splashScreen.SetActive(true);
 
     SceneManager.LoadSceneAsync("MountainCamp");
 }

Thinking this should load the new scene and show it, then unload the old scene. This happens however right before the new scene is displayed the main menu is shown just for a fraction of a second. So I found that possibly the old scene is unloaded first before the new scene is loaded so I tried this:

 void OnEnable() {
     SceneManager.sceneLoaded += OnLevelFinishedLoading;
 }
 
 public void OnLevelFinishedLoading(Scene scene, LoadSceneMode mode) {
     switch (scene.name) {
         case "MountainCamp":
             SceneManager.sceneLoaded -= OnLevelFinishedLoading;
             SceneManager.SetActiveScene(SceneManager.GetSceneByName("MountainCamp"));
             SceneManager.UnloadSceneAsync("MainMenu");
             break;
     }
 }
 
 public void MountainCampButton() {
     gameObject.SetActive(false);

     splashScreen.GetComponent<SplashScreen>().SetLevel("Mountain Camp");
     splashScreen.SetActive(true);

     SceneManager.LoadSceneAsync("MountainCamp", LoadSceneMode.Additive);
 }

Thinking I would be able to manually load and unload however this results in a warning in the load saying

Unloading the last loaded scene Assets/Levels/MainMenu.unity(build index: 0), is not supported. Please use SceneManager.LoadScene()/EditorSceneManager.OpenScene() to switch to another scene.

Which leaves my game still showing the main menu. Can anyone provide me with some assistance on making a smooth scene transition?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by RobAnthem · Dec 29, 2016 at 08:10 PM

Honestly, I've never had to Delegate onto the sceneLoaded for unloading purposes, since your code finishes step by step, I suggest adding the Unload section just below the load section. Also, SetActiveScene isn't necessary since your unloading the old scene, it will force the player to the only active scene. I've never had a problem with scene transitions, one downside sometimes is that if your scene is small then adding a loading screen might appear more like a flicker, which sometimes leads to dragging out a load beyond what was needed.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

61 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

AsyncOperation activating immediately even with async.allowSceneActivation = false; 0 Answers

SceneManager onActiveSceneChange Pause for a while before loading a new scene 0 Answers

Asynchronously Load a Scene, then switch to it on function call Unity 5.3 1 Answer

Android GAME Crashes After Splash Screen 2 Answers

WP8 - Changing splash screen from default causes app to crash after splash screen 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges