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 TruffelsAndOranges · Sep 27, 2015 at 11:09 AM · scene-loadinglevelasync

Loaded 2 async scenes: how to unload or remove 1 of them?

Basically I want to load 2 scenes, and then I want the player to be able to choose 1 of them to activate, using allowSceneActivation = true on one of the /AsyncOperation/, and I want to trash the other scene so I can load it at a later stage, or not load it all ever.

How do I do that?

I want something along those lines:

         AsyncOperation async1;
         AsyncOperation async2;
         AsyncOperation playerChosenAsync;
     
         void LoadSceneAsync(string sceneName1, string sceneName2){
                 AsyncOperation async1 = Application.LoadLevelAsync(sceneName1);
                 async1.allowSceneActivation = false;
         
                 AsyncOperation async2 = Application.LoadLevelAsync(sceneName2);
                 async2.allowSceneActivation = false;
         }
     
     void ActivateScene(AsyncOperation sceneToActivate){
         sceneToActivate.allowSceneActivation = true;
     }
     
     void TrashScene(AsyncOperation sceneToTrash){
         sceneToTrash.Trash(); // This method doesn't exist, 
                               // but I want to unload/delete do something here,
                               // to release memory/CPU/whatevs.
     }
 
     IEnumerator Update() {
             if(playerChosenSync == async1){
         TrashScene(async2);
        ActivateScene(async1);
       playerChosenSync = null;
 
 } else if(playerChosenSync == async2){
         TrashScene(async1);
        ActivateScene(async2);
       playerChosenSync = null;
       }
 }








Comment
Add comment · Show 3
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 dasm30 · Jan 11, 2016 at 05:00 AM 0
Share

Same issue here, I need to load 2 scenes (win, lose) and show one of them depending on the player's result in each $$anonymous$$i game. But when I try to load both, one of them just stays in the inspector as "not loaded", even when I quit play mode, and it can't be removed, I have to close Unity and open it again.. This is happening in Unity 5.3.0 and 5.3.1

avatar image TruffelsAndOranges dasm30 · Jan 11, 2016 at 08:55 AM 1
Share

Yea it's currently impossible to load 2 scenes simultaneously (at least using the Unity API). You have to activate 1 scene before you start loading another scene. $$anonymous$$ind of weird, but that's how Unity has done it.

avatar image dasm30 TruffelsAndOranges · Jan 11, 2016 at 02:00 PM 0
Share

Then will just hope they fix that some day :/

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by lassade · Jan 11, 2016 at 02:32 PM

Give a look at this http://docs.unity3d.com/ScriptReference/SceneManagement.SceneManager.html i think is only for 5.3.

Im still working in a project made in 5.2 so i dont tried this functions yet.

Comment
Add comment · Show 4 · 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
avatar image lassade · Jan 11, 2016 at 02:39 PM 0
Share

If you are in the 5.2 and below i see some nice free plugins in the assets store dont remenber the name sadly.

But it works by placing every object in the scene inside a gameObject of the same name (and the name must be unique) so this way the script can just do:

 GameObject.Destroy(GameObject.Find(sceneName))
avatar image dasm30 lassade · Jan 11, 2016 at 02:44 PM 0
Share

Yeah I've also managed to do some workaround for the problem by just instantiating and destroying prefabs, but it will be much better if they allow multiple scene loading.

avatar image TruffelsAndOranges lassade · Jan 11, 2016 at 03:23 PM 0
Share

@lassade As said earlier, we have work arounds for this, but they are not very elegant. The new Scene$$anonymous$$anager does nothing to fix this (it handles the scenes the same way as before in terms of loading).

avatar image dasm30 · Jan 11, 2016 at 02:40 PM 0
Share

The Scene$$anonymous$$anager is just the new way of handling scenes in Unity 5.3, it still doesn't allow to load multiple scenes at the same time

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

31 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

Related Questions

AsyncOperation for SceneManager.LoadSceneAsync doesn't adhere to Application.backgroundLoadingPriority 1 Answer

What to consider for changing environment, using enable/disabled or new scene? 2 Answers

help please: Level Changing Scipt 1 Answer

How to implement a loading screen for a procedurally-generated level? 1 Answer

How to get references when load a new scene? 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