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 aboabed · May 08, 2016 at 06:36 AM · scenetransitionsmanagement

SceneManager.SceneLoad problem.

Since Unity was updated to its last version , the use of Application.LoadScene was obsolete , i started using SceneManager.LoadScene instead , and i had a big problem im unable to solve.

When i m in my main menu scene and i choose a level to play , it all loads perfectly , i load the splash screen and then load the scene number according to my choice in the main menu, but when i try to go back from my level to my main menu to choose another level , it loads back to my splash screen , loads my second level for a second , then go back to my main menu scene , and its driving me crazy.

i tried searching on the community for any bugs to that matter , but no luck.

anyone can relate or can give me a solution to this problem?

Comment
Add comment · Show 1
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
avatar image tanoshimi · May 08, 2016 at 06:58 AM 0
Share

You've clearly got a mistake, but without seeing your code, it's pretty impossible to point out where...

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by aboabed · May 08, 2016 at 09:19 PM

my game consists of 3 levels ( Scenes) , a splash Scene and a main menu Scene.

The main menu Scene is consisted of a GameObject Scene that is passed between different scenes, it have a script that hold the value of the next Scene , the script is called (SceneNumber) , when i choose a scene the character walks towards its specific collider that represent the scene.
MainMenuSceneSelect hold the collisions of that player with the specified scene collider.

MainMenuSceneSelect.cs

     public GameObject SurvivalScene;
     public GameObject EndlessRunScene;
     public GameObject TrollScene;
     GameObject scene;
 
     void Start()
     {
         scene = GameObject.FindGameObjectWithTag ("Scene");
 
     }
 
     
     void OnTriggerEnter(Collider other)
     {
         if (other.gameObject == SurvivalScene) {
 
             SceneManager.LoadScene (4);// Loads the splash scene
             scene.GetComponent<ScenesNumber>().sceneNumber = 1;  //each represents the scene number in build
         } else if (other.gameObject == EndlessRunScene) {
 
     
             SceneManager.LoadScene (4); // Loads the splash scene
             scene.GetComponent<ScenesNumber>().sceneNumber = 2; //each represents the scene number in build
 
         
         } else if (other.gameObject == TrollScene) {
             
             SceneManager.LoadScene (4);// Loads the splash scene
             scene.GetComponent<ScenesNumber>().sceneNumber = 3; //each represents the scene number in build
 
         
         }
 
 
     }
 


after that the splash scene is loaded , i put an object to collide with a specific gameobject to end the splash scene and go to the specified scene number in the GameObject Scene , that holds the next scene number.

//note : i already made the Scene gameobject not to be destroyed on load .. // DontDestroyOnLoad()

EndSplash.Cs :

     public GameObject troll;
     GameObject scene;
 
     void Start () {
         scene = GameObject.FindGameObjectWithTag ("Scene");
     }
 
     void OnTriggerEnter(Collider other)
     {
         if (other.gameObject == troll) {
             if (scene.GetComponent<ScenesNumber> ().sceneNumber == 0) {
                 Destroy (scene);   //destroy the Scene Gameobject in case of returning to the mainmenu scene so we dont have doubles of Scene GameObject.
                 SceneManager.LoadScene (scene.GetComponent<ScenesNumber> ().sceneNumber);
 
             } else {
                 SceneManager.LoadScene (scene.GetComponent<ScenesNumber> ().sceneNumber);
             }
     
         }
     }
 
 

now , the first time we do that it all works fine , the intended scene gets loaded and there is no problems at all , but when i use the pause menu to return to the MainMenu Scene by

PauseManager.cs

     GameObject scene;
 
     void Start () {
         
         Time.timeScale = 1;
         scene = GameObject.FindGameObjectWithTag ("Scene");
 
     }
     
     // Update is called once per frame
     void Update () {
 
         if (CrossPlatformInputManager.GetButton ("Pause")) {
             Time.timeScale = 0;
 
         } else if (CrossPlatformInputManager.GetButton ("Resume")) {
         
             Time.timeScale = 1;
         }
          else if (CrossPlatformInputManager.GetButton ("MainMenu")) { // for the menu return 
             Time.timeScale = 1;
             SceneManager.LoadScene (4); // the splash scene 
             scene.GetComponent<ScenesNumber>().sceneNumber = 0;
 
         }
     }
 
 
 and it loads the MainMenu Scene without any problems , the double is destroyed and i have a GameObject Scene in the MainMenu Scene and its all good. 

the problem is when i try to do the exact same thing all over again , the second i load the splash screen into any scene , the splash screen is reloaded and it goes directly to the main menu scene all over again without even starting the intended level.

i hope i've been specific enough for you to understand my problem.

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Different scenes or single scene for a space rpg ? 1 Answer

Creating a scene: instantiating a prefab in a scene or use pre-instantiated prefabs? 1 Answer

memory management strategy 0 Answers

good resource about conserving memory when multiple levels share resources? 0 Answers

Does Unity have an equivalent to CCDirector? 1 Answer


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