Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. Unity 2020 LTS & Unity 2021.1 have been released.
    Dismiss Notice
  3. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Advanced Multi-Scene - Now Available

Discussion in 'Assets and Asset Store' started by Jodon, Feb 2, 2016.

  1. Jodon

    Jodon

    Joined:
    Sep 12, 2010
    Posts:
    434
    If you send me a small case that demonstrates this, I will verify it. Cheers.
     
  2. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    685
    There is an minimal example called
    Scenes/Foundation

    Scenes/Foundation
    • This is the scene you transition to from Bootstrap.
    • "Load *" buttons will open other scenes additively.
    • "Unload *" buttons will unload scenes that have been additively loaded.
    on
    https://github.com/Unity-Technologies/Addressables-Sample.

    This is the exactly the method i use.

    Also some other nice little demos.
    You can find and install Adressables in the PackeManager.
     
  3. Jodon

    Jodon

    Joined:
    Sep 12, 2010
    Posts:
    434
    Hey KeepOnShading,

    I've tried the example and it does work, but there are some caveats. Right now, all of the cross-scene references are saved via scene name. There's code that detects a rename and hooks everything up again, but if your intent is to rename your scene a bunch of times that's inadvisable but not impossible. The other thing is that because of this, we're not using the Addressables system specifically -- your code would be in charge of loading the desired scene, and AMS would then check to see if any of its cross-scene reference scenes are open, and if so, hook-up the references.

    I'm not sure what you're intending to achieve with the Addressable system, but I hope that answers your questions.
     
  4. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    685
    Thanks for checking. I will purchase and try.
    I mainly started with adressables to handle the 4GB problem on builds and finally it became a stable solution.
    Main XR Scene loads additive very big addressable production cars (around 4GB each) and environments. Historically the are some functions in these car who are referencing to main scene objects or environment. For these your cross scene references could be a temp solution.
     
  5. armnotstrong

    armnotstrong

    Joined:
    Mar 3, 2017
    Posts:
    19
    Hi,

    we find that cross scene reference of Camera not working. but other gameobject's cross scene reference works just fine



    After running in the editor

     
    keeponshading likes this.
  6. Jodon

    Jodon

    Joined:
    Sep 12, 2010
    Posts:
    434
    Hello Armnotstrong,

    Thanks for the comprehensive bug report. The issue in this case is described in this post. A work-around is in the same post. I'll consider adding this to the list of expansion code that's currently being used for Timeline / Cinemachine.
     
    keeponshading likes this.
  7. mr_blahblah

    mr_blahblah

    Joined:
    Jan 15, 2016
    Posts:
    37
    Hey!

    I'm a long-time user and admirer of this package, never had any problems until Unity 2018.3.11f1, but now I have massively long load times (feels as if Unity is freezing or crashing), and the console yields a 'The scene is not loaded' error.

    The Cross Scene References components are all unticked on scene load as well, for some reason. Any ideas?


    ArgumentException: The scene is not loaded.
    UnityEngine.SceneManagement.Scene.GetRootGameObjects (System.Collections.Generic.List`1[T] rootGameObjects) (at C:/buildslave/unity/build/Runtime/Export/SceneManager/Scene.cs:91)
    CodingJar.GameObjectEx.GetRootObjectsEvenIfNotLoaded (UnityEngine.SceneManagement.Scene scene) (at Assets/Packages/CodingJar/Common/GameObjectEx.cs:100)
    CodingJar.GameObjectEx.FindBySceneAndPath (UnityEngine.SceneManagement.Scene scene, System.String absolutePath) (at Assets/Packages/CodingJar/Common/GameObjectEx.cs:157)
    CodingJar.MultiScene.UniqueObject.RuntimeResolve () (at Assets/Packages/CodingJar/MultiScene/Scripts/UniqueObject.cs:88)
    CodingJar.MultiScene.UniqueObject.Resolve () (at Assets/Packages/CodingJar/MultiScene/Scripts/UniqueObject.cs:132)
    CodingJar.MultiScene.RuntimeCrossSceneReference.get_fromObject () (at Assets/Packages/CodingJar/MultiScene/Scripts/RuntimeCrossSceneReference.cs:70)
    CodingJar.MultiScene.AmsCrossSceneReferences.ConditionalResolveReferences (System.Collections.Generic.List`1[T] references) (at Assets/Packages/CodingJar/MultiScene/Scripts/AmsCrossSceneReferences.cs:259)
    CodingJar.MultiScene.AmsCrossSceneReferences.ResolvePendingCrossSceneReferences () (at Assets/Packages/CodingJar/MultiScene/Scripts/AmsCrossSceneReferences.cs:240)
    CodingJar.MultiScene.AmsCrossSceneReferences.Awake () (at Assets/Packages/CodingJar/MultiScene/Scripts/AmsCrossSceneReferences.cs:132)
    UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
     
  8. Jodon

    Jodon

    Joined:
    Sep 12, 2010
    Posts:
    434
    Hello Mr Blahblah,

    I'm at a trade show until Friday this week, so can't take a good look at it until then. That said, I have active projects on 2018.3.10 without any issues. It's possible some internal functionality has changed. What I would recommend trying is looking at the GetRootObjectsEvenIfNotLoaded code and trying the pre-2017 path (using the reflection call). If that doesn't solve it, try re-ticking the components and resaving.

    If you can send me a small repro case I can look at what's going on, but probably on Friday rather than sooner.

    Cheers.
     
  9. Bubsavvy

    Bubsavvy

    Joined:
    Sep 18, 2017
    Posts:
    45
    Hey Jodon,

    I am not sure what happened, but as of Unity 2019.1.0f2 the UI Element build for setting scene types : Dont Load, Additive, etc. is broken. We cannot change these options now. No errors in the console to report. Just not doing the expected behavior.

    Thanks,
    Bubsavvy
     
  10. Jodon

    Jodon

    Joined:
    Sep 12, 2010
    Posts:
    434
    Hey, I'm traveling in rural Japan at the moment, so WiFi isn't great. It will be a few days before I can grab that version of Unity. In the meantime, can you just use the Inspector to set those settings? You'll find them on the ! AmsMultiSceneSetup GameObject.
     
  11. peeka

    peeka

    Joined:
    Dec 3, 2014
    Posts:
    110
    unity 2019 has subscene, when I create a subscene it added a AmsMultiscenesetup to it, now the scene is confused which scene depend which scene.
     
  12. Jodon

    Jodon

    Joined:
    Sep 12, 2010
    Posts:
    434
    There's a checkbox on the MonoBehaviour that says it it's the Main Scene or not. You want to uncheck it for the sub scenes.
     
  13. Bubsavvy

    Bubsavvy

    Joined:
    Sep 18, 2017
    Posts:
    45
    Hey Jodon,

    As of Unity Version 2019.1.10f1 we cannot save scenes with cross scene references. This occurs even without adding/modifying/removing cross scene references. A simple scene edit causes it like adding a new gameobject to the scene. The error is the following :

    Assertion failed on expression: 'm_SerializedObject->m_SerializedObjectVersion == m_SerializedObjectVersion'
    UnityEditor.SerializedProperty:get_objectReferenceInstanceIDValue()
    CodingJar.MultiScene.Editor.AmsSaveProcessor:HandleCrossSceneReferences(IList`1) (at Assets/CodingJar/MultiScene/Editor/AmsSaveProcessor.cs:125)
    CodingJar.MultiScene.Editor.AmsSaveProcessor:EditorSceneManager_sceneSaving(Scene, String) (at Assets/CodingJar/MultiScene/Editor/AmsSaveProcessor.cs:27)
    UnityEditor.EditorApplication:Internal_CallGlobalEventHandler()
     
  14. Jodon

    Jodon

    Joined:
    Sep 12, 2010
    Posts:
    434
    Hey Bubsavvy,

    What version did you upgrade from? I've just run the testbed on 2019.2.0b7 and I'm not receiving any of these issues. I'll upgrade to the latest 2019.2 but I'm wondering if a bug snuck into 2019.1.10 seeing as it was only released a few days ago.

    Edit: I've confirmed it's a bug in the latest Unity. You can try to work-around it by modifying this code:

    Around the exception (AmsSaveProcessor.cs line 125) change to:

         
    var obj = xRef.fromProperty.objectReferenceValue;
    refIdToRestore = obj ? obj.GetInstanceID() : 0;
    xRef.fromProperty.objectReferenceInstanceIDValue = 0;
    xRef.fromProperty.serializedObject.ApplyModifiedPropertiesWithoutUndo();
     
    Last edited: Jul 15, 2019
  15. Bubsavvy

    Bubsavvy

    Joined:
    Sep 18, 2017
    Posts:
    45
    Hey Jodon,

    I upgraded from 2019.1.9f.

    Thanks for the update.
     
  16. Bubsavvy

    Bubsavvy

    Joined:
    Sep 18, 2017
    Posts:
    45
    I just checked the patch. Doesn't seem to fix it.
     
  17. Bubsavvy

    Bubsavvy

    Joined:
    Sep 18, 2017
    Posts:
    45
    Hey @Jodon,

    It was actually an issue with unity prefabs ultimately. The error still occurs, but the save issue is Unity Prefab related. Just letting you know.

    Thanks for looking into it,
    TrollHouseGames
     
  18. malyKuba

    malyKuba

    Joined:
    Jan 30, 2013
    Posts:
    7
    Hi, first of all - super helpful plugin. Keep it up :)

    I have problem that bothers me for some time now. Sometimes when I change value in inspector and save scene I get this error (especially when I change Controller on Animator. That's super strange...):
    I can press play, but when I do, I get hundreds of errors like this:
    and very often some game objects in scene just disappear and only fix is to discard changes.

    I was trying to log the file that causes the problem by putting Debuge.Log just before
    SerializedObject so = new SerializedObject(obj);
    but it prints out this:
    So I don't believe that's the issue.

    Any idea what is the root of evil? Or maybe some tip how to better debug this error?

    Thanks for your help.
     
  19. Jodon

    Jodon

    Joined:
    Sep 12, 2010
    Posts:
    434
    Hey malyKuba,

    I believe what's happening here is that you have a variable probably named m_GameObject in your class somewhere. Unity has a bunch of hidden under-the-hood variables with names you're not allowed to conflict with. Typically their names follow that pattern: m_VariableName (you'll see them when you load a scene in a text editor). Can you double-check that you don't have a variable named that way in your class? When you catch that callstack, you can check what object you're serializing -- it may be hard to catch the callstack without a lot of step-throughs because it won't throw an exception that can be caught.

    Cheers.
     
  20. Hawk0077

    Hawk0077

    Joined:
    Nov 6, 2017
    Posts:
    728
    Hi, I recently came upon the 4gb filesize limitation in unity and so have divided my scene into: terrain, static objects, lights, water etc.

    Now when I do a build only the first scene loads so will this asset solve that and load all scenes when I do a build and play mode.

    Of course its ok in the editor playmode but not in the build.

    Also, the merge scene function... does that create large files again or use separate files?

    Many thanks
     
  21. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    685
    Last edited: Dec 3, 2019
  22. Jodon

    Jodon

    Joined:
    Sep 12, 2010
    Posts:
    434
    Hey Hawk0077,

    Are you building a 64-bit application? It sounds like you're running into the 32-bit memory limit. This asset does not address that memory limit because once all of your assets are loaded (and are above 4gb) you'll hit that 32-bit memory limit. Check your build settings to make sure you're using 64-bit mode (x64).

    Cheers.
     
    Hawk0077 likes this.
  23. Hawk0077

    Hawk0077

    Joined:
    Nov 6, 2017
    Posts:
    728
    Thanks, but no, thats not the issue. Its unity scene filesize limit. But I split the scene up and that issue is solved.

    I actually have a scene loader now but your asset looks promising to use (if its possible) just to benefit from the Cross Scene Referencing.

    Can your asset be used just to take advantage of that feature?
    And play nice with another scene loader?

    Many thanks.
     
  24. Jodon

    Jodon

    Joined:
    Sep 12, 2010
    Posts:
    434
    Yes, my asset does cross-scene referencing but in order to use it, you must have at least those two scenes loaded in the editor (the source scene and the destination scene). You can disable the other features of Advanced Multi-Scene by just setting the Scenes to "DontLoad" in the Editor, and thus using your own scene management to load them yourself.
     
    Hawk0077 likes this.
  25. Hawk0077

    Hawk0077

    Joined:
    Nov 6, 2017
    Posts:
    728
    Thanks Jodon, much appreciated. I will get it in a while as I am just trying to fix something. Thanks again.
     
  26. FabioZocklabs

    FabioZocklabs

    Joined:
    Jul 11, 2019
    Posts:
    13
    I just bought this Plugin and it works well for simple use cases, but it seems not to work with prefabs.
    I wanted to have a scene, which is always active and just contains a bunch of global objects. I wanted to reference these objects inside multiple prefabs, and the UI did show the objects, but they weren't saved.
    Isn't there a way to reference other scenes from prefabs?

    I found a way, which seems to work sometimes:
    * move Prefab to scene without cross scene references
    * add the references to the prefab
    * copy the AmsCrossSceneReferences script of the scene into the prefab
    * replace the source objects with the correct objects
    * now when adding this prefab to a scene, the AmsCrossSceneReferences script from the current scene will update when saving and contain the new reference

    But this approach feels like a hack to me and doesn't always work.
    It would be cool, if it also works inside prefabs correctly.

    And if it's not possible, they should at least not be selectable from prefab edit mode.
    The approach, I'll use now is making the global objects prefabs, which will work, but also lacks some features, I have, when they are in an active scene (default behavior of MonoBehaviour (Start, Update, etc.), changes done to prefabs will stay after finishing playing).
     
    Last edited: Dec 11, 2019
  27. Jodon

    Jodon

    Joined:
    Sep 12, 2010
    Posts:
    434
    Hey FabioZocklabs,

    I have not seen this attempted before, and indeed it was not actually designed for this use case. To solve it in a general case is a lot more difficult than it may seem as you're able to reference Prefabs without instantiating them. However, the code itself could support a particular use case where you're instantiating them, if that's what you want to achieve. The references are saved as UniqueObjects which have a Resolve() function on them. It would be a matter of having this function run upon any prefab instantiation. There would have to bee some kind of bookkeeping to always check if you're dragging a scene reference onto a prefab -- that seems kind of clumsy / hacky but could be done.

    Let me know if you need further assistance; I could consider supporting something like this.
     
  28. Goooooooogle

    Goooooooogle

    Joined:
    Sep 30, 2016
    Posts:
    11
  29. Jodon

    Jodon

    Joined:
    Sep 12, 2010
    Posts:
    434
    Hello,

    The link you've supplied is to a generic issue and doesn't relate to my plug-in. Do you have a reproducible case? What version of Unity are you using? Can you supply the call stack?

    If this is an immediate issue, can you check your AmsCrossSceneReferences MonoBehaviour to see if there's any old cross-scene references laying around there? That could be the cause of such an issue, though I haven't seen any other reports of this.

    Cheers.
     
  30. looytroop

    looytroop

    Joined:
    Jun 22, 2017
    Posts:
    54
    I am using multi-scene currently and am setting my scenes to "Baked" loading. However, when I hit play, it bakes the scenes into the main scene as expected, however, it also never unloads the scenes that should be baked, meaning I have duplicate of every object in those specified scenes.
     
  31. Jodon

    Jodon

    Joined:
    Sep 12, 2010
    Posts:
    434
    Hey Looytroop,

    What version of Unity are you on? Are you loading the scene yourself manually, or is this immediately when clicking play? Are you getting any null references / scripting exceptions upon hitting play?
     
  32. chrisk

    chrisk

    Joined:
    Jan 23, 2009
    Posts:
    694
    Hi, I just found this Asset and it's very interesting it let you work with multi-scene.
    I'm trying to find out if it's possible unless it already supports, to have it work with Addressable.

    Addressable is pretty much a requirement if you want to service your game these days and I'm trying to create the scene using Addressable.

    Here is the setup.

    1. I have a separate Static Map Project because usually the static scene takes the most of art resources and a large number of asset can slow the Editor down. I just make sure this Static Map Project will contain just a static scene that doesn't change in the game(like buildings), therefore, you can think of this as ReadOnly object.

    2. Then, I build the static map as addressable and export.

    3. And then, I load the exported static addressable scene into the Main Project because I still have to add dynamics scene objects such as vehicles on top of the Static Scene. But the problem is Addressable cannot be loaded into Editor but it loads fine during runtime. I think it might be possible to load the static addressable scene as a readonly object but I'm not sure how. We won't edit them as Addressable and if we have to edit, we will have to edit them in the Static Map Project and re-export.

    I hope I explained what I'm trying to do clearly. If your Asset can work with Addressable and I think it will help many people who are suffering from the clunky Editor.
    Besides helping the editor to work faster, it also makes sense to have an independent map project for map artists.

    I'm looking forward to hearing some good answers. If it's technically impossible without Unity's help, we can ask Unity to add the support together.

    Cheers!
     
  33. looytroop

    looytroop

    Joined:
    Jun 22, 2017
    Posts:
    54
    @Jodon This is on Unity version 2018.4.10f1.

    I am not loading the scene manually, I have a main scene, with external scenes dragged into the hierarchy, and their load type set to "Baked" and then I hit play.

    I am not getting any null references. I also went into the Advanced Multi-scene script and looked for the Baked Loading script. I notice that it utilizes a built in Unity function
    SceneManager.MergeScenes( scene, gameObject.scene );


    I added a check after this point
    if(scene.isLoaded)
    {
    Debug.LogError("Scene Loaded");
    }

    However, when stepping through the code, at the point where the scenes are merged, scene is set correctly, after this point, scene is set to index -1, and the scene says it is unloaded. However, in the actual game, in play mode, the scene is clearly loaded still and the objects exist in the main scene as well as the child scene from which they originated.
     
  34. fwalker

    fwalker

    Joined:
    Feb 5, 2013
    Posts:
    171
    Active Scene changes on play.

    I need a little help. We are using Advance-multiscene in our project. We have a main scene that is our active scene, and then 4 other additional scenes, all works ok, but when we "Play" the active scene changed to the last scene loaded.
    Is there something that needs to be set to avoid this, and keep the Active scene as it is?

    Thanks
     
  35. Jodon

    Jodon

    Joined:
    Sep 12, 2010
    Posts:
    434
    Hey, do you have it set as the Active Scene? You'll see one Scene is in bold -- the one that's set to the active scene. It could be that Unity loads that.
     
  36. Jodon

    Jodon

    Joined:
    Sep 12, 2010
    Posts:
    434
    Hey Looytroop,

    I've been using 2019.2.x with no major issues this past week. I joined the GGJ and we were able to put out a game using the plug-in without any hitches; I realize that's not 2018.4.10f1 but I've worked on another major product that uses AMS heavily in the 2018.x branches so I don't think it's compatibility...

    The loading order of Unity is a bit weird and wonky. It's not unusual for Unity to have isLoaded return false while the load is happening, or if you're doing the Domain switch between Playmode and Editmode. Two quick things to check:

    Is the active scene (the scene that's bold) the top-scene that you're loading? If not, try switching that by right-clicking on it before you hit Play.

    Another thing to check is that only the top-level scene is marked as "Is Main Scene" in the AmsMultiSceneSetup behaviour. If the other scenes are also marked as "Is Main Scene" it will pull in whatever scenes they reference -- which could be what's happening.

    If both those things checkout as false, can you try building a small repro case and sending it to me either on here or the e-mail in the readme file? Thanks.
     
  37. Jodon

    Jodon

    Joined:
    Sep 12, 2010
    Posts:
    434
    Hey Chrisk,

    I was avoiding answering this because I haven't read-up too much on Addressables. I found the presentation of the system kind of clunky as you've described and have thus far avoided it. The workflow you're describing is exactly what this plug-in was built to address, but it does not use Addressables and I'm not entirely sure it's compatible. If you send me a small project with what you're trying to achieve I can verify it.

    If you're just using Addressables to solve this workflow issue, then I would suggest just using my plug-in as the tutorial videos have suggested since it solves the same issue. If you're using Addressables because you need to send the data over the internet, then I'd have to verify that the plug-in doesn't break any of those exports. Off the top of my head, I'd say that as long as the assets live together in the same package it shouldn't break. You can disable the auto-loading of the scenes, load them however you wish, and still get the cross-scene reference functionality to work.

    Cheers.
     
  38. chrisk

    chrisk

    Joined:
    Jan 23, 2009
    Posts:
    694
    Hi, Jodon,
    It appears that Addressables cannot be loaded into the Editor. Unless Unity supports it, I'll have to find a workaround.
    I'll try to push Unity as much as possible until then.

    For a workaround, please let me ask you this. Let say we have two projects, A, and B. Project A contains a scene that only has Static Map Data. Let's call the scene Scene A. And I want to load the Scene A into Project B.
    In Project B, I have Scene B that will contain Dynamic elements that lay on top of Scene A.
    Can your asset help you work with a multi-scene that crosses over different projects?

    If so, how do you go about doing that?
    I suppose I'll have to export Scene A as a package and Project B will import the Scene A package. But I'm not sure if it will work as if they are from the same project. Please let me know and I think it will greatly improve the workflow.

    Cheers!
     
  39. fwalker

    fwalker

    Joined:
    Feb 5, 2013
    Posts:
    171
    Right. Yes, the scene that needs to be active shows in bold and with the word "active" in bright green next to it in the Hierarchy tab. Then we play and the last scene (I tested it and it is always the last scene in the list) in our list becomes bold :( LIke this:

    Capture1.PNG Capture2.PNG

    That is our complete list. Then if I remove the KenziesHouseQuad, CastleQuad becomes active when we play again.

    Capture3.PNG

    My impression is that Unity sets the last scene as the active scene by default and the AmsMultiSceneSetup is not dealing properly with that case? But I want to make sure this is the case before I start messing with the code in
    AmsMultiSceneSetup, as I am surprised this would not already be handled by AMS. I could also write a workaround which will simply consist of saving the information on who is the active scene before play and then resetting the active scene when all the scenes are loaded.
    .
     
  40. looytroop

    looytroop

    Joined:
    Jun 22, 2017
    Posts:
    54
    Hey! I believe I figured out the issue. I think that there were cross scene references that were not attached properly and were generating warnings. Once I cleaned those up it worked perfectly.
     
    Jodon likes this.
  41. Jodon

    Jodon

    Joined:
    Sep 12, 2010
    Posts:
    434
    Hey, sorry for the late response, my notifications aren't working again. Unity does not set the last scene as the active scene -- at least not any version I've used. Can you subscribe to the activeSceneChanged event, set a breakpoint and let me know what you see?
     
  42. Jodon

    Jodon

    Joined:
    Sep 12, 2010
    Posts:
    434
    Hey chrisk,

    No, you cannot load data in from another project. There is nothing that stops a cross-scene reference from working across projects (they're done by scene/path look-up) but you wouldn't be able to preview it in the Editor. My gut feeling tells me you should be looking at some other method to cut-down your project load times rather than maintaining multiple projects. There is supposed to be a semi-loaded mode in Unity where the assets aren't fully in memory until they're referenced. You should be able to take advantage of that by not loading in the sub-scenes until you have to actually connect the cross-scene references.

    Cheers.
     
  43. fwalker

    fwalker

    Joined:
    Feb 5, 2013
    Posts:
    171
    How would I go about getting an event, or knowing when ALL the scenes have been loaded?
    In order to load the scenes you ask for the Active scene to be loaded calling :

    Code (CSharp):
    1.  levelLoadingProcess = SceneManager.LoadSceneAsync(_global.g.levelToLoad);
    2.   levelLoadingProcess.completed += LoadingLevel_completed;
    However LoadingLevel_completed gets called once the active scene has loaded but prior to the other additive scenes loading ! :(
     
  44. Jodon

    Jodon

    Joined:
    Sep 12, 2010
    Posts:
    434
    It can be fairly tricky to know if all of your scenes are loaded. First, you must know that you've actually kicked off all of your loading. Once you've got that sorted, there's two strategies and unfortunately my machine isn't configured to verify this:
    1. You can use SceneManager.sceneCount in certain versions of Unity that will include scenes still loading -- check to see if that's a viable solution. You can get SceneManager.GetSceneAt(idx).isLoaded. Note that the load callbacks, including the completed callback of the AsyncOp you're using are going to fire after the scene has gotten its Awake/Start. That's why I have a callback in AmsCrossSceneReferences called HandleNewSceneLoaded (to get the callback earlier).
    2. If the above fails for you, you can simply keep track of the all of the asyncOps in a static list and just check them all against .isDone.
    Basically you either rely on Unity to give you the scenes list or you have to keep track of them yourself. You can only do this after you've called the loading for all of your scenes (load them from a central place). If you're using my plug-in, the central location is AmsMultiSceneSetup (there is a list of scenes configured to load and they all have associated AsyncOperations).

    Cheers.
     
  45. fwalker

    fwalker

    Joined:
    Feb 5, 2013
    Posts:
    171
    Thank you Jodon, I think that helped a little. I saw the list of SceneEntrys I did not realize that there was access to asyncOp in there! :)
     
    Jodon likes this.
  46. FabioZocklabs

    FabioZocklabs

    Joined:
    Jul 11, 2019
    Posts:
    13
    I have a problem with my current setup.
    I have multiple scenes, all of them declared as main scene, including one or a few other scenes by default (the same for all).
    All the main scenes result in an interconnected world.
    The other main scenes are loaded in dynamically.

    Now I want to load in all my main scenes into the editor at once by creating a new scene as main scene, which stores all other scenes.
    This basically works, but when I save, all the other scenes will now also load the other scenes using the automatic setup, i.e. the AMSMultiSceneSetup script will automatically be updated for all scenes, not only the active scene, so saving will destory the setup.

    The simple solution would be to not automatically update AMSMultiSceneSetup script for scenes, which are currently not active. This would replicate what I currently do, but without the risk to automatically save unwanted changes.

    Another idea, that might work, is specifying "Don't Load" for a scene.
    But this won't help in the editor. The whole scene will be loaded anyway.

    EDIT:

    I found a solution for the first behaviour by editing AMSMultiSceneSetup

    Just add this line to method `OnHierarchyChanged` directly after `var activeScne = ...`:

    ```
    if (_thisScenePath != activeScene.path) return;
    ```

    Not sure, if this solves all cases, but I guess, that's it.

    I think, it's a good idea if you include this change, since you normally don't want to edit scene setups of other scenes, when not editing it as active scene.
     
    Last edited: Jul 8, 2020
  47. Jodon

    Jodon

    Joined:
    Sep 12, 2010
    Posts:
    434
    Hey FabioZocklabs,

    The flag for "is main scene" is used to communicate if AmsMultiSceneSetup should pull in the other scenes automatically. The problem with your suggested change is that it can break other plug-ins (i.e. the active scene is just where new GameObjects go, not necessarily the top-level scene). If that change works for you, that's great. I will think about this some more and see if there's a better solution... I think the plug-in is due for an update soon.
     
  48. FabioZocklabs

    FabioZocklabs

    Joined:
    Jul 11, 2019
    Posts:
    13
    I found an even better solution for me:
    I just redefined _isMainScene:

    Code (CSharp):
    1. bool _isMainScene { get => SceneManager.GetActiveScene() == gameObject.scene; }
     
  49. Jodon

    Jodon

    Joined:
    Sep 12, 2010
    Posts:
    434
    Just be careful about doing this. I change what is the "Active Scene" during my own workflow to add objects into other levels. I'll continue to look for a robust solution.
     
  50. FabioZocklabs

    FabioZocklabs

    Joined:
    Jul 11, 2019
    Posts:
    13
    Right, the problem with this is, when I switch active Scene, the new active scene will update the MultiSceneSetup automatically, so I don't want to save it.

    Maybe a setting to disable automatic update on switching active scene would help. And then you'd have to update manually, at least when switching active scene and wanting to update it.

    But still feels more like a workaround than a good solution.
     
unityunity