Search Unity

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
    StoreBackground.png
    After weeks of testing and bug fixing, my latest plug-in, Advanced Multi-Scene is now available on the Asset Store.

    The plug-in addresses some of the shortcomings of using Unity's built-in Multi-Scene features. Features include:
    • Automatic save and restore of your multi-scene setup in editor
    • Automatic load of your scene setup at runtime (with options on how to load)
    • Ability to 'bake' (merge) a sub-scene into your main scene at build-time, reducing load times and alleviating order-dependent script issues.
    • Automatic save & restore of cross-scene references in the editor AND at runtime, allowing a reference from Scene-A to correctly reference an object in Scene-B.
    Here is a video showing off the plug-in and highlighting some Unity functionality as well as the features of the plugin:



    Asset Store Link
     
    Last edited: Feb 18, 2016
  2. MatthewHarmon

    MatthewHarmon

    Joined:
    Mar 5, 2015
    Posts:
    24
    Hi Jodon:

    This looks great, and I appreciate all the work you must have been doing to keep AAS playing nicely with the rapid pace of Unity updates.

    Here's a question about AMS for you... will you be able to tuck a subscene under a node in the hierarchy, or must they all live at the root level? I loved (and built my architecture around) the fact that AAS references could be anywhere.

    Thanks!

    Matt
     
  3. Jodon

    Jodon

    Joined:
    Sep 12, 2010
    Posts:
    434
    Unfortunately not. I tried convincing the developers this was desirable but failed. As it currently stands, no reparenting of a scene and you are unable to load the same scene multiple times without first merging a scene. I'd be extremely happy if you brought up this functionality in a more visible place because it always looks like I'm the only one advocating these features and I think Unity thinks I'm crazy. :)
     
    hopeful likes this.
  4. Tony707

    Tony707

    Joined:
    Jun 15, 2015
    Posts:
    38
    Hi Jodon,

    We're really insterested into this new plugin, when do you plan to release it ?

    Thank you.
     
  5. Jodon

    Jodon

    Joined:
    Sep 12, 2010
    Posts:
    434
    It's awaiting approval from the Asset Store.
     
    Tony707 likes this.
  6. Jodon

    Jodon

    Joined:
    Sep 12, 2010
    Posts:
    434
    Tony707 and hopeful like this.
  7. Tony707

    Tony707

    Joined:
    Jun 15, 2015
    Posts:
    38
    Hi Jodon,

    Some feedbacks on this first version:

    - AmsMultiSceneSetup is created when saving the active scene only in case it has pending modifications.
    - AmsMultiSceneSetup is only created in case the Cross Scene reference is set to "Save" (not UnityDefault)
    - AmsMultiSceneSetup is not created in the other scenes when dragging them in the active one.

    Is AmsMultiSceneSetup mandatory on non main scenes in case we do not use cross scene references ?

    Despite these little issues it works well ;)

    Thank you.
     
  8. Jodon

    Jodon

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

    Yes, those appear to be a few oversights when not using cross-scene references.

    The AmsMultiSceneSetup object is not mandatory on non-main scenes, but it is difficult to determine if a scene is going to be a main scene or not (hence the checkbox). I believe Unity internally marks the scene as the "active scene" during the save process, so there's not a whole lot we can do about that.

    For now, I don't have a good strategy to detect a new scene is opened (apparently that API is coming in 5.4), so I can't do much to address points 1 and 3, but have made an effort to address point #2. Please send me an e-mail if you'd like the beta.

    Cheers.
     
    Tony707 likes this.
  9. WF_Bart

    WF_Bart

    Joined:
    Apr 16, 2014
    Posts:
    29
    Hey Jodon,

    AMS is working well! We did encounter one problem that may have more to do with Unity than with AMS though, but perhaps you could still take a look at it.

    When you bake a NavMesh with multiple scenes open, the navmesh file gets baked in a directory named after the active scene. The file gets REFERENCED, however, by every scene you currently have open. So in our case we have subscenes that are used by multiple scenes, and they just accumulate navmeshes. Then you end up with either an error that navmesh settings have to be the same, or if every scene has the same settings, with multiple navmeshes on top of each other (which, in case you're wondering, confuses the hell out of navmesh agents).

    Our current stop-gap solution is to bake the navmeshes for every main scene, then open all the subscenes seperately and clear their navmeshes (or revert changes to the other scenes with version control). It works, but it's not really ideal.
    It'd be nice if there were some way to bake navmeshes ONLY to the active scene (or even only to a selected subscene).
     
  10. Jodon

    Jodon

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

    Indeed we've had that issue and it is a Unity issue. What we do is right-click on the scene and hit "unload scene" on all scenes you don't want referencing (or contributing to) the NavMesh. You can then re-open them after the bake.

    You can use this same strategy if you bake your lightmaps you'll also encounter a similar issue where it will bake for all open scenes, but generates a new lightmap per scene. The issue with lightmaps is that regardless of your geometry in those scenes, having four or more scenes opened just killed my machine by running out of memory.

    Glad everything else is working for you.
     
  11. CGPepper

    CGPepper

    Joined:
    Jan 28, 2013
    Posts:
    152
  12. Jodon

    Jodon

    Joined:
    Sep 12, 2010
    Posts:
    434
    Send a PM about my e-mail address. But the rest of the issues are that you need to avoid the cross-scene referencing in Awake(). The reason is that even though it'll work in a real build when baking, the Editor callbacks are a frame behind (it's a Unity issue). For this reason you need to push your initialization code from Awake() to Start() and hopefully the issues will be solved after that.

    There's a new beta that I've been working on to resolve some issues with cross-scene references and baked levels. I haven't yet submitted it to the store but when you send me an e-mail I'll send you the latest.

    Cheers.
     
  13. hermit_purple

    hermit_purple

    Joined:
    Jun 27, 2014
    Posts:
    11
    Hi, I've just purchased the plugin and testing it out. It looks like reference in UnityEvent listener does not get save. For example, uGUI's Button class has a OnClick UnityEvent which user can add listeners to. Having a reference to another scene and saving the main scene produce the following error:

    Ams Plugin: Could not perform a runtime resolve on cross-scene reference TestScene'/Base Level' (UI.Button).m_OnClick.m_PersistentCalls.m_Calls,0.m_Target => TestScene2'/Static' (GameObject).
    Reason: Cross-Scene Ref: TestScene'/Base Level' (UI.Button).m_OnClick.m_PersistentCalls.m_Calls,0.m_Target => TestScene2'/Static' (GameObject). Could not Resolve fromObject . Please review Documentation.
    UnityEngine.Debug:LogErrorFormat(Object, String, Object[])
    CodingJar.MultiScene.AmsDebug:LogError(Object, String, Object[]) (at Assets/CodingJar/MultiScene/Scripts/AmsDebug.cs:59)
    CodingJar.MultiScene.Editor.AmsCrossSceneReferenceProcessor:SaveCrossSceneReferences(List`1) (at Assets/CodingJar/MultiScene/Editor/AmsCrossSceneReferenceProcessor.cs:205)
    CodingJar.MultiScene.Editor.AmsSaveProcessor:HandleCrossSceneReferences(IList`1) (at Assets/CodingJar/MultiScene/Editor/AmsSaveProcessor.cs:72)
    CodingJar.MultiScene.Editor.AmsSaveProcessor:OnWillSaveAssets(String[]) (at Assets/CodingJar/MultiScene/Editor/AmsSaveProcessor.cs:35)
    UnityEditor.GenericMenu:CatchMenu(Object, String[], Int32)
     
  14. Jodon

    Jodon

    Joined:
    Sep 12, 2010
    Posts:
    434
    You're quite right, the serialization path was more tricky than I expected. I've got a fix, e-mail me at the address in the Documentation and I'll send you the beta fix. Everyone else can expect a fix submitted to the store in the next week.

    Cheers.
     
  15. hermit_purple

    hermit_purple

    Joined:
    Jun 27, 2014
    Posts:
    11
    If there are two components of same type in the same game object, the serialization has trouble distinguish them. In some cases it throws error (for two PlayMaker FSM in the same object), other times it only saves one of the references (each component have a UnityEvent) without any warning. I know that the path is ambiguous in this case but is there a way around it? At the very least throw error if it can't correctly serialize it.
     
  16. Jodon

    Jodon

    Joined:
    Sep 12, 2010
    Posts:
    434
    The path is ambiguous. It should be throwing an error. It's next on my TODO list to fix this (so the serialization does work, and CAN be distinguished). Send me an e-mail if you want the beta, I'm going to be working on it later this week.

    Cheers.
     
  17. ConjuringTheFuture

    ConjuringTheFuture

    Joined:
    Feb 19, 2014
    Posts:
    19
    Hey Jodon,

    Now that GDC is finished my team and I are interested in updating from Unity 5.1 and the last version of AAS to Unity 5.3 and AMS.

    I was wondering if you might have some advice as to the best way for us to approach the update, since our game is relatively large and makes heavy use of nested subscenes.

    Each of our levels are broken into a number of room subscenes, and each of those rooms have quite a few subscenes of their own. So on average a level is comprised of well over 200 individual scenes. I've looked at the upgrade section of the readme for the new AMS and upgrading everything by hand as described in that document seems like it would be a huge pain.

    We're also sort of at a loss on how we are going to handle the loss of nested subscenes and how that is going to affect our workflow. I had substantially extended AAS for the team, as well as built a number of internal tools which used AAS's features extensively.

    For instance I made a room generating wizard for the level design team so they could easily make setup a room with all it's need subscenes from a template file:


    And here you can see a shot of our internal level map / portal editor, as well as a shot of our hierarchy so you can see how our levels are generally setup:


    It has a number of features like drag an drop a scene from the project view and auto add it to the hierarchy as a sub scene.

    I want to keep to be able to keep the subscenes in the individual rooms because it's really nice for situations like when the environment artists are tweaking geo in Level_Static and the animator is working in the cinimatics subscene without any conflicts ect.

    But It seems like our work flow is going to need to substantially change once we upgrade.

    I was just wondering is you might have any advice for me to help make the transition as smooth as possible for my team.

    Thanks for your work and we've really enjoyed what AAS has allowed us to do so far.
     
  18. Jodon

    Jodon

    Joined:
    Sep 12, 2010
    Posts:
    434
    Hello,

    That's quite a substantial workflow. I have made changes to Advanced Additive Scenes since 5.3 came out which should allow you to sunset AAS over time (i.e. it should work in 5.3). In one of my AAS projects, I have imported Advanced Multi-Scene and the two currently co-exist before we're ready to finish the switch. Depending on your expected lifecycle of this project (e.g. if it is maintenance-only / critical fixes only) you may be able to get away with AAS for the remainder of your development.

    Having said that, AMS brings better cross-scene referencing support which will work even with additive-ly loaded scenes (which I would guess is what you're trying to achieve -- a sort of streaming system?) The cross-scene references also work without modifying the destination scene, so it's a bit nicer. It's also the system currently in development, and follows the Unity-"blessed" workflow of no SubScenes.

    You wouldn't want to manually convert this project over. You would need to write a conversion script. Here's a strategy I would use. Start by having the plug-ins live side-by-side in Unity 5.3.


    Old SubScenes to Multi-Scenes
    • Make sure all of the SubScenes are loaded
    • Unlock all of the SubScenes (this restores the cross-scene references)
    • Call SceneManagerment.NewScene and give it a name like AMS-OldName for every SubScene
    • Inverse-transform the AAS SubScene Objects, move them to the root, then use SceneManagement.MoveGameObject to move those objects to the newly created scene.
    • Optional: Save the scenes now, and do a sanity check to make sure your cross-scene references are intact
    • Destroy the now-empty AAS GameObjects.
    • Destroy the AAS placeholder objects (e.g. ! SceneData).
    • Save
    If your workflow relies on the hierarchy of the SubScenes, you're in a bit more trouble. You can write scripts to reparent at runtime (if using Additive Loading) or during the baked step (using Baked Loading). Note: There's a bit of kludge right now for the baking process due to some incompatibilities with Unity's method which will hopefully be alleviated in 5.4 (it exists in two places - one for running in Editor and one for the actual build).

    One of the nice things about AMS is I've released it as source-code only, so no building DLLs which became unwieldy with the amount of Unity releases there are. For that reason when you grab the package, you have the full source code right there and the functionality is a lot easier to manage so hopefully your custom editor scripts will be easier to port over.

    Hope this helps.
     
  19. Jodon

    Jodon

    Joined:
    Sep 12, 2010
    Posts:
    434
    A new beta is available for those who have issues with the following:
    - fixed some issues when building with Scenes set to Baked
    - allowing multiple instances of the same component type for cross-scene referencing (e.g. referencing a second collider).

    If you'd like to test, please send me an e-mail at the address in the documentation file.
     
  20. XCompWiz

    XCompWiz

    Joined:
    Jan 6, 2016
    Posts:
    5
    I have a main scene with additional 4 baked scenes running in the editor.

    In my current test I'm seeing the loading order of the objects be rearranged and muddled. It would seem that some components reach Update before other components even do Awake even on the same object.
    From what I understand, the way AMS handles the cross-scene references and reloading is by killing and recreating things, and doing this it means that objects don't obey normal initialization order at all.
    I have a component which other components on the same object look for and register to (on Start); if they don't find that component they kill themselves. If the container component finds itself empty on Update it kills itself.
    ---The container is killing itself, but the registering objects aren't, which would suggest they are getting Start called after the container gets it's first update.---
    [Edit (Correction): Upon further inspection, I noted that not all of the objects with such containers were having issues. I revise my previous assessment. I now believe that the components are being swapped out piecemeal in a relatively arbitrary order resulting in the registering components registering themselves to a component that is then destroyed and remade, resulting in it being empty. Odd, as the container has no cross-scene references. I'll test this hypothesis.]
    Can you work/are you working to improve this? Are there workarounds?

    It also seems that Awake happens before the cross-references are reapplied. Is this the "baked scenes in editor issue"?

    Is there an ETA on when the beta will really release? Depending on the timeframe I might send you an email about that beta test.

    Thanks! The plugin offers really great functionality and works well outside of the quirks mentioned here and in your post above.

    [Edit (Addendum): Tested hypothesis above. Seems to be correct; the component is destroyed containing registrations. I managed a workaround by getting the components on the container's OnEnable rather than having them register, but this limits their power. I'm not sure why the component is killed and recreated if it has no cross-scene references to apply, but this makes it sound like the issue could actually be caused by the editor timing issues. I'm not sure of the extent of that.

    I have one last issue I've not seen elsewhere: does the cross-scene referencing not support arrays/lists? I have an object which refers to objects in other scenes as a list. The list doesn't seem to get populated properly.]

    [Edit (Addendum 2): Does the cross-reference replacement happen after Awake on a component? Is that an editor issue? Is it fixed in the beta / being worked on?]
     
    Last edited: Mar 21, 2016
  21. Jodon

    Jodon

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

    Yes, the cross-scene referencing occurs after Awake, and possibly after a Start/Update. This is true for scenes loaded additively (which occur at runtime), but unfortunately also true for baked scenes when in the Editor. This is an engine-level issue and is supposed to be fixed in Unity 5.4, though I haven't gotten around to testing it yet (and probably requires some code changes to use new functionality).

    One of my projects uses similar "Singletons" where other classes try to register to them early. This can be alleviated somewhat by dragging the scene that contains those singletons further up the hierarchy so they load earlier. Another solution is to use something like I've done below. Note on the code below that each scene of mine uses a state machine to determine flow, and the initial state is basically "wait until everything is ready, then proceed to the real first state":

    Code (CSharp):
    1.     void OnEnable()
    2.     {
    3.         StartCoroutine( WaitThenAdvance() );
    4.     }
    5.  
    6.     System.Collections.IEnumerator WaitThenAdvance()
    7.     {
    8.         while ( isActiveAndEnabled )
    9.         {
    10.             yield return new WaitForEndOfFrame();
    11.  
    12.             for(int i = 0 ; i < SceneManager.sceneCount; ++i)
    13.             {
    14.                 var scene = SceneManager.GetSceneAt(i);
    15.                 if ( !scene.IsValid() || !scene.isLoaded )
    16.                     continue;
    17.             }
    18.  
    19.             break;
    20.         }
    21.  
    22.         yield return new WaitForEndOfFrame();
    23.         yield return new WaitForEndOfFrame();
    24.  
    25.         // We're done!
    26.         _stateMachine.NextState();
    27.     }
     
  22. ConjuringTheFuture

    ConjuringTheFuture

    Joined:
    Feb 19, 2014
    Posts:
    19
    Jodon,

    Can the source version of AAS live side by side with AMS?
     
  23. Jodon

    Jodon

    Joined:
    Sep 12, 2010
    Posts:
    434
    Yes, the classes should be in separate namespaces if you're up to date with AAS.
     
  24. ConjuringTheFuture

    ConjuringTheFuture

    Joined:
    Feb 19, 2014
    Posts:
    19
    importing AMS over the source version of AAS seems to want to overwrite a number of AAS's scripts and vice versa



    Seems like depending on the order you try to import them you either end up with `SceneData' could not be found. or `AmsDebug' could not be found.
     
  25. ConjuringTheFuture

    ConjuringTheFuture

    Joined:
    Feb 19, 2014
    Posts:
    19
    Seems like the issue is with unity's importer. When I import them separately then manually bring them together it seems to work fine.
     
    Jodon likes this.
  26. XCompWiz

    XCompWiz

    Joined:
    Jan 6, 2016
    Posts:
    5
    My guess is they have the same asset ids in the meta data. :) Should be possible to break up on Jodon's end, but it's a bit tedious.

    Thanks, @Jodon. :) I'll try the beta build and see how it goes.
    Using some kind of delayed initialization would be workable, but is somewhat frustrating as it makes Awake and Start less useful and OnEnable unreliable.

    [EDIT: Beta does indeed seem to fix the cross-reference to/from multiple instances of a component on an object.
    However, I'm still seeing the issue with my lists not being repopulated. It loads them in the editor, but at runtime they remain empty. The length of the list is correct, but the entry is null. Thoughts?]
     
    Last edited: Mar 22, 2016
  27. Jodon

    Jodon

    Joined:
    Sep 12, 2010
    Posts:
    434
    Re: Delayed Initialization issues: Yeah that sucks, but my hands are tied. I was talking with the multi-scene editing engineer and he let me know that 5.4 has the ability to load a scene within the same frame which would solve it.

    About the missing cross-scene references, I do not know for sure. There should be something in the log. Under Edit / Preferences there's also an option for verbose logging (in the Editor) which could help if you're seeing the issues while Play-in-Editor is going. If you can clean-up the logs and send me the relevant points I might be able to track it down.

    Cheers.
     
  28. XCompWiz

    XCompWiz

    Joined:
    Jan 6, 2016
    Posts:
    5
    Nothing shows up in the editor as is. I'll get back to you with more info as I manage to obtain it. :)

    The issue only seems to occur in the editor. In the actual build the scenes are baked so the references are preserved without issue. Not sure if it's just the scene being baked together that does it; hard to say, but likely.

    Thanks!
     
  29. TomLansdale

    TomLansdale

    Joined:
    Apr 6, 2013
    Posts:
    11
    Hi Jodon,

    I'm also using AMS with Unity 5.3.4f1, and am noticing some odd behaviour on play-in-editor.

    I have a main scene and 4 Baked multi-scenes (Game, StaticGeometry, Dialogue, Lighting). The main scene has an object with cross-references into the Game multi-scene, and the Game multi-scene has some cross-references into the Dialogue multi-scene. I can see that these are all hooked up properly, and can verify this by inspecting the various ! AmsMultiSceneSetup objects and checking out their cross-scene references.

    When I run the level, the cross-scene references seem to just vanish, and never come back. In some cases (main -> Game) they return when play is stopped. In other cases (Game -> Dialogue) they remain removed. Unlike the above mails this doesn't appear to be simply coming in late or in an unpredictable order - they're disappearing entirely. :(

    Any answers or workarounds would be greatly appreciated, many thanks!
     
  30. Jodon

    Jodon

    Joined:
    Sep 12, 2010
    Posts:
    434
    Tom,

    If you haven't already, upgrade to the latest AMS version (0.534p1). Version 0.534 had some issues but was only on the store for about a day. If that doesn't solve your issue, then enable debug logging in the Edit / Preferences menu and send me the log of when your level loads.

    Just to confirm, the links are there in the editor, but when you hit play they disappear and never return? If so I'll need the debug log of the start-up procedure which will indicate if it saved the cross-scene reference and if it tries to restore but fails.

    Cheers.
     
  31. TomLansdale

    TomLansdale

    Joined:
    Apr 6, 2013
    Posts:
    11
    Hi Jodon, thanks for the reply. I will update AMS and let you know how it goes.

    The links are there in the editor, across multi-scenes. I hit play and they immediately get set to "None", and never get set (I can also see that the baked scenes have been correctly merged into one scene at runtime). I then stop play-in-editor and the links return. I'll get you a log if the update doesn't help.

    Many thanks!
     
  32. TomLansdale

    TomLansdale

    Joined:
    Apr 6, 2013
    Posts:
    11
    Hi Jodon - 0.534p1 fixed my problems with cross-scene references, thank you very much!

    I have a new problem with lightmaps though :( What is the expected workflow for lightmaps and baked AMS scenes? I have all of them open and bake my lightmap, which generates a LightingData asset with four sub-assets, and looks how I would expect it to look in the editor. However, when I run the game, it's not working and there's a directional light in the Z-axis illuminating everything - any thoughts on this, or is it a wider Unity bug?

    Thanks again for all your help.
     
  33. Jodon

    Jodon

    Joined:
    Sep 12, 2010
    Posts:
    434
    Good news.

    Can you try switching those scenes over from Baked to LoadAdditive? It's possible there's an issue with the MergeScenes functionality. We ended up shipping the majority of our scenes (and all lightmapped ones) with LoadAdditive. The lightmapping stuff was supposed to be fixed in Unity 5.3 but it's possible it got broken again and I haven't been actively testing the Baked path for lightmapping.
     
  34. TomLansdale

    TomLansdale

    Joined:
    Apr 6, 2013
    Posts:
    11
    This fixed it immediately. Many thanks!
     
    hopeful likes this.
  35. TomLansdale

    TomLansdale

    Joined:
    Apr 6, 2013
    Posts:
    11
    Hi Jodon,

    What's the best way to unload an additively-loaded scene which itself has additively-loaded AMS scenes? Currently if I load up my scene, it loads and brings with it its four additive AMS scenes (exactly as I need it to). But when I naively do a SceneManager.UnloadScene on that scene, it gets unloaded but leaves those four extra scenes loaded (unsurprising, but not what I want in this case).

    Is there a good way to have the scene unload its additively-loaded AMS scenes as it is unloaded, or could we easily find out which scenes it has loaded so I can manually unload them at the same time?

    EDIT: I'm using the current code... it seems to work but it'd be good to know if there's anything insanely wrong here :)

    Code (CSharp):
    1.                 // Some temporary(?) code to delete additive multi-scenes
    2.                 Scene the_scene = SceneManager.GetSceneByName( level_data.UnitySceneName );
    3.                 if( the_scene != null && the_scene.IsValid() )
    4.                 {
    5.                     GameObject[] root_objects = the_scene.GetRootGameObjects();
    6.                     for( int i=0; i<root_objects.Length; i++ )
    7.                     {
    8.                         CodingJar.MultiScene.AmsMultiSceneSetup ams = root_objects[i].GetComponent<CodingJar.MultiScene.AmsMultiSceneSetup>();
    9.                         if( ams != null )
    10.                         {
    11.                             System.Collections.ObjectModel.ReadOnlyCollection<CodingJar.MultiScene.AmsMultiSceneSetup.SceneEntry> entries = ams.GetSceneSetup();
    12.                             foreach( CodingJar.MultiScene.AmsMultiSceneSetup.SceneEntry entry in entries )
    13.                             {
    14.                                 if( entry.loadMethod == CodingJar.MultiScene.AmsMultiSceneSetup.LoadMethod.Additive ||
    15.                                     entry.loadMethod == CodingJar.MultiScene.AmsMultiSceneSetup.LoadMethod.AdditiveAsync )
    16.                                 {
    17.                                     SceneManager.UnloadScene( entry.scene.name );
    18.                                 }
    19.                             }
    20.                         }
    21.                     }
    22.                 }
    23.  
    24.                 SceneManager.UnloadScene( level_data.UnitySceneName );
     
    Last edited: Apr 4, 2016
  36. Jodon

    Jodon

    Joined:
    Sep 12, 2010
    Posts:
    434
    Hi Tom,

    That code looks "correct". There is a tricky case where you're using for instance a GUI that is loaded additively. Multiple scenes can reference this GUI scene and you do not want it unloaded, so it's actually fairly tricky to solve in a general case. There should also be shortcuts to get those scene objects in my GameObjectEx class rather than doing the GetRootGameObjects() iteration yourself. Cheers.
     
  37. MFKJ

    MFKJ

    Joined:
    May 13, 2015
    Posts:
    264
    Hi Jodon,
    I have a main scene, contains Models, Animation, Lighting, Terrain/Environment, Scripting etc. I divide that main scene into multiple sub-scene(according to their discipline) as this plugin suggested. Now the project have shared with my teammates all are working their respective scene.
    My question is that: how this plugin will help me to sync my teammates update into my project while all other members working on different PCs/Laptops. Is there real time sync facility available using this plugin?
    Additionally, I want to ask that how this plugin will help in scripting? How my developers will take advantages of this plugin?
     
  38. Jodon

    Jodon

    Joined:
    Sep 12, 2010
    Posts:
    434
    Hello,

    The plug-in does not do any syncing with your team. That is up to you to decide. Unity advocates using their new Collaboration platform. I would saying setting up a Subversion server is the way to go. You can go to http://www.assembla.com to get a paid server or set one up yourself. There's also free options like Github and BitBucket (but they use Git which I do not recommend for Unity development, especially if you're a beginner to Git).

    When you're using a source control system, there are inherent issues when two or more people modify the same file. This causes a "merge conflict" in complex files like Unity scenes because there's data all-over that file and it's not very localized. Tools like Unity's YAML Merge attempt to solve this, but you'll find it fails in complex cases. This plug-in sits on top of Unity's system which allows you to break-up your scenes so that one person in an area (e.g. art) can "own" that scene and avoid the merge conflicts. With Unity's implementation, you could not reference any components across scenes and this plug-in takes care of that for you. It also stores and reloads your setup per-scene.

    Cheers.
     
  39. MFKJ

    MFKJ

    Joined:
    May 13, 2015
    Posts:
    264
    Hi Jodan,
    Thanks for your prompt response. The things you were mention in your post I already familiar but some additional information I got i.e., don't use git with unity(debatable) etc. Thanks again.
    At first plugin Image indicate me that your plugin will help me to collaborate with my team but this is not the case. It will just help me to manage main scene with the help of different sub-scene and it will also help to save its settings. But you know this functionality we can achieve our self by writing some simple code(Like load scene additive etc). This will not help us to collaborate. If i use this plugin My team still have to send me the sub-scene updates to me using package etc it can be sync directly which i were assuming. One Scene - One Team motto were lead me to this thinking.
    Can you define me that this plugin help me in team collaboration in any respect/dimension?

    Anyway thanks for your this efforts.
     

    Attached Files:

  40. Jodon

    Jodon

    Joined:
    Sep 12, 2010
    Posts:
    434
    Hello,

    That is the picture for my older plug-in (Advanced Additive Scenes) which was released two years ago (though I've been updating it every couple of months). It brings Multi-Scene functionality to all versions of Unity after 4.3. The thread you're currently in is for Advanced Multi-Scene which brings the useful features of AAS into the new Unity Multi-Scene workflow.

    The AMS functionality (as described on the store page) is the ability to save cross-scene references, bake scenes into the build so they don't load incur an additional delay of loading at runtime, and have the scene auto-load the other scenes which are considered a part of it.

    Sounds like what you're looking for is a Git/Subversion/Mercurial/Perforce replacement which this plug-in certainly is not. I would also advise against searching for such a plug-in as there's a reason why those software packages have been around so long, and it's because solving distributed file storage is a very hard issue and you don't want software that has only been tested on a handful of projects in that case (you want something that's been around for a decade or more and proven itself).

    What I would suggest doing is creating a Subversion repository somewhere (if you're uncomfortable with setting up projects in general, I would just use Assembla). Then, have your team use that repository for their commits and syncs. This will ensure you're all up-to-date and there's a central location that is known to be "the project", not on someone's hard drive somewhere. After you've got that working, you use this plug-in to break-up your scenes so that each person on your team has a specific area to work in where they know no one else is touching. E.g. The artist can own the Static-Geometry scene and knows that if they make a change to that scene, everyone else's work will not overwrite their own. The benefit is that everyone can load up the main scene (e.g. Level01) and see exactly how everything fits together, even though they're working on only a small portion of the scene.

    It's going to be hard to simply describe the benefit you'll see if you've never used version control before, because one of the greatest benefits of the plug-in is to avoid the merge conflicts that occur because of version control. For this reason, the vast majority of my customers appear to be small teams (and some large ones) that use version control and are tired of having their work stomped by other team members.

    Cheers.
     
    Adrad likes this.
  41. Etrain

    Etrain

    Joined:
    Nov 3, 2013
    Posts:
    11
    Hi,
    We've recently upgraded from AAS to AMS with Unity 5.3.4 and are having issues getting the additional scenes to build to WebGL. Basically, only one scene is ever included in the build, even if we choose the "bake" option for additive scenes. No errors are produced during the build.

    Is WebGL supported at the moment?
     
  42. Jodon

    Jodon

    Joined:
    Sep 12, 2010
    Posts:
    434
    Yes, it should be. The build process should be the same for all platforms. I've just tested WebGL on Unity 5.3.4f1 and it passes the majority of my unit tests (including the one that loads). There's nothing in the log that indicates an issue (build or runtime?) Have you tried switching to Additive?
     
  43. WF_Bart

    WF_Bart

    Joined:
    Apr 16, 2014
    Posts:
    29

    Hey Jodon & everyone,

    Unfortunately I do want those scenes contributing (they contain level geometry) to the navmesh, but not referencing it (because they are used by different parent scenes).

    To solve it, I've written a short script that uses reflection to access the navmeshdata after baking and save only to the active scene. It also has an option for setting the navmeshdata of all subscenes to null.


    If anyone can make use of it, feel free! Be sure to put it in an Editor folder.
    Code (csharp):
    1.  
    2. using UnityEditor;
    3. using UnityEditor.SceneManagement;
    4. using UnityEngine.SceneManagement;
    5. using System;
    6. using System.Reflection;
    7. using System.Collections.Generic;
    8.  
    9. public class BuildNavMeshes
    10. {
    11.     static SceneSetup[] openscenes;
    12.     static string activescene;
    13.  
    14.     public static UnityEngine.Object navmeshBuilder_SceneNavMeshData
    15.     {
    16.         get
    17.         {
    18.             var navmeshdata = typeof(NavMeshBuilder).GetProperty("sceneNavMeshData", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null, null);
    19.             return (UnityEngine.Object)navmeshdata;
    20.         }
    21.         set
    22.         {
    23.             var field = typeof(NavMeshBuilder).GetProperty("sceneNavMeshData", BindingFlags.NonPublic | BindingFlags.Static);
    24.             field.SetValue(null, value, null);
    25.         }
    26.     }
    27.  
    28.  
    29.     [MenuItem("NavMesh/Bake to Active Scene")]
    30.     public static void MenuButtonBuildNavMesh()
    31.     {
    32.         BuildNavMeshForMultipleScenes(false);
    33.     }
    34.  
    35.     [MenuItem("NavMesh/Clear SubScene navmeshes")]
    36.     public static void MenuButtonBuildNavMeshOverwrite()
    37.     {
    38.         BuildNavMeshForMultipleScenes(true);
    39.     }
    40.  
    41.     private static void BuildNavMeshForMultipleScenes(bool clearSubscenes)
    42.     {
    43.         activescene = EditorSceneManager.GetActiveScene().path;
    44.         openscenes = EditorSceneManager.GetSceneManagerSetup();
    45.         List<string> paths = new List<string>();
    46.         foreach (SceneSetup s in openscenes)
    47.         {
    48.             paths.Add(s.path);
    49.         }
    50.         buildMethod(paths.ToArray(), clearSubscenes);
    51.     }
    52.  
    53.     private static void buildMethod(string[] paths, bool clearSubscenes)
    54.     {
    55.         for (int index1 = 0; index1 < paths.Length; ++index1)
    56.         {
    57.             for (int index2 = index1 + 1; index2 < paths.Length; ++index2)
    58.             {
    59.                 if (paths[index1] == paths[index2])
    60.                     throw new Exception("No duplicate scene names are allowed");
    61.             }
    62.         }
    63.         if (!EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo())
    64.             return;
    65.  
    66.         NavMeshBuilder.BuildNavMesh();
    67.         UnityEngine.Object sceneNavMeshData = navmeshBuilder_SceneNavMeshData;
    68.  
    69.         navmeshBuilder_SceneNavMeshData = sceneNavMeshData;
    70.         EditorSceneManager.SaveScene(SceneManager.GetActiveScene());
    71.  
    72.         EditorApplication.delayCall += () =>
    73.             {
    74.                 for (int index = 0; index < paths.Length; ++index)
    75.                 {
    76.                     if (paths[index] != activescene && clearSubscenes && EditorSceneManager.OpenScene(paths[index]).IsValid())
    77.                     {
    78.                         navmeshBuilder_SceneNavMeshData = null;
    79.                         EditorSceneManager.SaveScene(SceneManager.GetActiveScene());
    80.                     }
    81.                 }
    82.                 EditorSceneManager.RestoreSceneManagerSetup(openscenes);
    83.             };
    84.     }
    85. }
    86.  
    Edit: Put in a delay so it doesn't conflict with AMS' save processor restoring cross-scene references.
     
    Last edited: Apr 15, 2016
  44. TomLansdale

    TomLansdale

    Joined:
    Apr 6, 2013
    Posts:
    11
    Hi Jodon,

    I have my level scenes, each of which have four additively-loaded AMS scenes.

    My top-level wrapper loads the level scenes asynchronously. I need to know when the level scene AND all of their AMS scenes have been loaded, is there any way to query the AMS system for its async load progress? My wrapper scene can track the progress of the scenes it is loading directly but has no visibility on the scenes they are loading in turn via AMS.

    Alternatively and preferably - has the issue with "Baked" scenes and lightmaps from post #33 been resolved? This would be a better route for me as it would better mirror how we're approaching using AMS and fix all the associated problems with "Additive" AMS scenes.

    Many thanks!

    Tom
     
  45. Teila

    Teila

    Joined:
    Jan 13, 2013
    Posts:
    6,932
    We purchased this during the sale and now the website is gone and we cannot access any documentation. Is this asset still viable? We can't even get the contact info for the developer because it goes to the dead website.
     
  46. Jodon

    Jodon

    Joined:
    Sep 12, 2010
    Posts:
    434

    Still going strong... not sure what's up with the website but I've contacted the host. The package comes with a documentation file. What can I help you with?
     
  47. Teila

    Teila

    Joined:
    Jan 13, 2013
    Posts:
    6,932
    Thanks, Jodon. I will post here if I have questions. At the moment, we have moved on to something else and will come back to Multi-Scene. I never thought to check inside the package! Sorry about that.
     
  48. Jodon

    Jodon

    Joined:
    Sep 12, 2010
    Posts:
    434
    Sorry Tom, I think this post fell through the cracks. I couldn't see post numbers on mobile and I let it slip out of my browser history.

    In short, that bug should have been fixed mid-April and we have a project that uses Baked Scenes fairly extensively, though never off indirect loadlevels. We have a bunch of code in our VR game that waits until all levels are loaded before "fading in" the scene to avoid motion sickness. The code looks like this:

    Code (CSharp):
    1.     private static bool AreAllScenesLoaded()
    2.     {
    3.         for (int i = 0 ; i < UnityEngine.SceneManagement.SceneManager.sceneCount ; ++i)
    4.         {
    5.             if ( !UnityEngine.SceneManagement.SceneManager.GetSceneAt(i).isLoaded )
    6.                 return false;
    7.         }
    8.  
    9.         return true;
    10.     }
    Cheers and sorry!
     
  49. Stevepunk

    Stevepunk

    Joined:
    Oct 20, 2013
    Posts:
    205
    Can this be used with procedurally generated scenes?
    eg. similar to minecraft - scenes are generated and saved as the player moves around and chunks are loaded and unloaded.
     
  50. Jodon

    Jodon

    Joined:
    Sep 12, 2010
    Posts:
    434
    Sort of. This plug-in is mostly useful for previewing how the scenes will fit together in the Editor. This plug-in could be used to stream levels together, but procedural stuff is best suited to use the built-in Unity functionality since the levels you are loading are known only at runtime. Cheers.