Search Unity

  1. Calling all beginners! Join the FPS Beginners Mods Challenge until December 13.
    Dismiss Notice
  2. It's Cyber Week at the Asset Store!
    Dismiss Notice

Advanced Multi-Scene - Now Available

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

  1. WagDan

    WagDan

    Joined:
    Nov 7, 2014
    Posts:
    36
    Hi @Jodon

    I would like trigger the additive loading on UI button press at runtime, unload the scene again on button press, and be able to juggle the loading of scene in and out using the UI. I'm trying to do this to save on RAM used by multiple loaded scenes.

    I feel like I should be able to set the scene to "Additive on button press" and drag the main scene manager script into the UI so I can load and unload a certain scene on a toggle or buttons.

    Any advice or help would be appreciated. Loving the asset so far, but I had imagined the above functionality would be included and I can't work out how to hack it to do this
     
  2. Jodon

    Jodon

    Joined:
    Sep 12, 2010
    Posts:
    419
    Hello,

    This functionality would be outside of the plug-in (and is built into Unity). This plug-in is to visualize levels that are broken up at edit time (and to load them automatically and properly at runtime with the cross-scene references intact). I will paste some code to achieve what you want, but I want to caution you that you're probably not going to be saving that much memory and you'll need to add Resources.UnloadUnusedAsset calls: http://www.slideshare.net/flashgamm/unity-internals-memory-and-performance.

    Here's some code. You can add this to a GUI Button and then hook-up the callback to the Button's callback:

    Code (CSharp):
    1.  
    2. using UnityEngine;
    3. using UnityEngine.SceneManagement;
    4.  
    5. public class LoadLevelOnButtonPress : MonoBehaviour
    6. {
    7.    [SerializeField]   string       _levelName;
    8.    [SerializeField]   LoadSceneMode   _loadMode;
    9.  
    10.    public void MsgLoadLevel()
    11.    {
    12.      SceneManager.LoadScene( _levelName, _loadMode );
    13.    }
    14.  
    15.    public void MsgUnloadLevel()
    16.    {
    17.      SceneManager.UnloadScene( _levelName );
    18.    }
    19. }
    20.  
     
  3. WagDan

    WagDan

    Joined:
    Nov 7, 2014
    Posts:
    36
    Thank you. I wrote something along these lines. Thanks for the tip on Resources.UnloadUnusedAsset
     
  4. ELineCEng

    ELineCEng

    Joined:
    Sep 13, 2014
    Posts:
    8
    Hi Jodon,

    I am exploring Advanced Multiscene 0.54f1 with Unity 5.4.2f2 for use in my studio's next project. We like that AMS leverages Unity's multiscene workflow and we are especially interested in AMS' cross-scene reference support. Unfortunately, we have discovered that our studio's custom visual scripting tool and AMS are not cooperating with each other regarding cross-scene references. We could use your guidance to resolve our issue.

    Whether saving a scene, leaving that scene, and returning to that scene in UnityEditor, or just entering play mode in UnityEditor, we find our tool losing its cross-scene references indefinitely. Our tool serializes its own internal, secondary data depending on the absence or presence of any referenced object (for example, assigning its own IDs to those referenced objects), and we believe AMS directly setting cross-scene references to zero is tripping up our tool's assumptions held during the set of ISerializationCallbackReceiver callbacks, if not circumventing those callbacks entirely.

    For example, when saving, leaving, then returning to a scene, AMSSaveProcessor.HandleCrossSceneReferences first does:

    xRef.fromProperty.objectReferenceInstanceIDValue = 0;
    xRef.fromProperty.serializedObject.ApplyModifiedPropertiesWithoutUndo();

    which causes an OnBeforeSerialize callback to our tool. Our tool notices the reference is gone and clears its internal data accordingly. AMSSaveProcessor.HandleCrossSceneReferences then does:

    xRef.fromProperty.objectReferenceInstanceIDValue = refIdToRestore;
    if( xRef.fromProperty.serializedObject.targetObject )
    xRef.fromProperty.serializedObject.ApplyModifiedPropertiesWithoutUndo();

    which DOES NOT cause any callback to occur to our tool, despite verifying that the second ApplyModifiedPropertiesWithoutUndo call occurs. Consequently, our tool enters a bad state where the reference is restored but was not given an opportunity to restore its internal data accordingly. Even if we force a callback to our tool to give that opportunity, we have been unable to get this corrected state written to disk--perhaps UnityEditor is unaware that we are changing state behind its back. Our efforts in informing UnityEditor thus far have been unsuccessful.

    So our question is: is there a callback we are overlooking that would allow our tool to reliably detect when AMS manipulates our tool's references that are cross-scene? Is there a proper way to inform UnityEditor that our tool has changed state, similar to how ApplyModifiedPropertiesWithoutUndo seems to cause UnityEditor to dispatch callbacks?

    Thanks,
    Chris
     
  5. Jodon

    Jodon

    Joined:
    Sep 12, 2010
    Posts:
    419
    As you can image, this may be a complex issue, but definitely not unsolvable. Probably, because of the complexity, there are many ways to solve it and I would leave it up to you which one you think is best. Here are some implementation details followed by suggestions:

    Implementation Details

    • The saving of cross-scene references when entering playmode is AmsPlaymodeHandler and the implementation for saving is OnWillSaveAssets. Both call HandleCrossSceneReferences.
    • I've found OnBeforeSerialization to be bad for my purposes since the usage of the Unity API during that is forbidden and sometimes unreliable (there was threads on this during the betas). I've tried to move most of my stuff over to EditorApplication.hierarchyWindowChanged and I suggest you do the same if that's possible. That callback name is badly named, it just means "has any data changed" and runs in the proper thread for Unity API access.
    • You'll see lots of checks in my OnBeforeSerialization calls. I found those calls to be too frequent, and happening at different times (i.e. build times). Sometimes the results matter and sometimes they don't it seems (i.e. when building the current scene, the results sometimes make it into the build and sometimes don't). It's been a long time since I've looked at that code, so I've kinda just left it as-is for older Unity compatibility before I revisit it.

    Suggested Fixes

    Choose from one of the following:
    1. Move your code to EditorApplication.hierarchyWindowChanged if possible. This will save the most headaches.
    2. Add some static variables to determine if the cross-scene references are being zeroed out before the first ApplyWithoutUndo().
    3. You can add specific serialization steps for your plugin wherever I've used HandleCrossSceneReferences (just call it prior to that).
    4. If you don't like the callbacks explicitly, you can instead have a static bool AmsSaveProcessor.isPerformingCrossSceneReferences and check that in your OnBeforeSerialization.
    5. If you want zero-modifications, you can instead create your own UnityEditor.AssetModificationProcessor and PlaymodeStateChanged handler which will serialize before mine, then ignore my changes for a frame.
    Let me know which solution you go with and I can try to integrate the solution into my branch.

    Cheers.
     
  6. MrIconic

    MrIconic

    Joined:
    Apr 5, 2013
    Posts:
    176
    So I import Advanced Additive Scenes and then Advanced Multi-Scene only if I need 5.3 support? Since my menus only change when I import both.
     
  7. Jodon

    Jodon

    Joined:
    Sep 12, 2010
    Posts:
    419
    Advanced Additive Scenes is legacy (pre-5.3). It should only be used if your project has already been developed with AAS. If it's a new project, or you're just getting started using these plug-ins, you want to import only Advanced Multi-Scene.
     
  8. MrIconic

    MrIconic

    Joined:
    Apr 5, 2013
    Posts:
    176
    I see. Is there any downside to importing both? Since it works just fine once I put both in- and it reminds me of the original AAS that I know of. Just putting AMS in seems to do nothing though I notice that I wasn't getting the !AMSMultiScene object or any additional green/red text anywhere. So I probably missed doing something to make it work.

    (I'm using 5.4)
     
  9. Jodon

    Jodon

    Joined:
    Sep 12, 2010
    Posts:
    419
    Yes I would avoid importing both, and they both have scene post-processing functionality that attempts to save and resolve cross-scene references. Just use AMS. Read the documentation, watch the demo video, drag in your scenes, change something to dirty the scene then hit save.
     
  10. silentslack

    silentslack

    Joined:
    Apr 5, 2013
    Posts:
    268
    Hi,

    I'm having a problem with lightmaps. I'm using 'Baked' option for the subscenes. Lightmaps seem fine before Play (sub scenes look to have correct lighting & shadows) but on Play the lightmaps seem broken. Is this a known issue and is there a workaround?

    Thanks, Jake

    Edit: I've managed to get Lightmaps working using 'Additive' subscene type although I would like to get Baked working if possible!?
     
    Last edited: Dec 8, 2016
  11. Jodon

    Jodon

    Joined:
    Sep 12, 2010
    Posts:
    419
    I'm using a baked version in my own game. However, when you bake your maps you must make sure that only the baked map is loaded at bake time. Otherwise you'll get double-lightmaps being applied. If you think you've done that correctly (i.e. you can load each map separately and the lightmaps are correct), what you can try is reloading the scene in the Editor before hitting Play and seeing if that solves the issue (there was a bug for a while where lightmaps would be double-applied).

    Note that almost every different version of Unity works differently in this regard, so it may be that you're on a newer one that I've tested with (5.4.2 I believe is what we used last).
     
  12. silentslack

    silentslack

    Joined:
    Apr 5, 2013
    Posts:
    268
    Thanks for the input here. My level is divided up into subscenes who rely on each other for the lightmapping (lighting in one scene, static geometry in another etc) so I can't ensure just the one scene is loaded at bake time. I'm running 5.4.1f1, perhaps its specific to that version?
     
  13. Jodon

    Jodon

    Joined:
    Sep 12, 2010
    Posts:
    419
    Your scenes with lights must be loaded with the static geometry when you bake. That should probably work if you nuke the lightmap from the lighting scene after baking. You can see the issue fairly clearly if you load up the lighting panel and look at what lightmaps are loaded. Load the scenes separately to see which lightmaps are loaded with each scene, and then you'll see how they combine. Unity does not have this workflow solved in a great way, so you need to pay careful attention to which scenes and lightmaps you're baking. There's lots of threads on how they are not merging this data properly (especially light probes).
     
  14. Barabicus

    Barabicus

    Joined:
    Jun 5, 2013
    Posts:
    158
    Hey Jodon,

    so after having done a lot of searching and wrecking my head trying to figure out a clean solution to this the last week, I've come by AMS. I actually asked my question in the scripting thread awhile ago here https://forum.unity3d.com/threads/multi-scene-load-order.445437/ but to sum it up I want to be able to split my scenes into environment and controllers essentially. Controllers should be singletons. I wont get into it but instantiating a prefab if no reference exists will not really work for me. Since they can be switched in and out depending on the level.

    Since all scenes load one by one it means their Awake and Start calls can arrive at different times to what I need. The script execution order doesn't seem to work since they are split into different scenes. What I want is for all my scenes to load their objects all within the one Awake call then the one Start call. Prioritizing the script execution order. It seems baked scenes seem to do this so I was just wondering would this be a valid use of AMS?
     
  15. Jodon

    Jodon

    Joined:
    Sep 12, 2010
    Posts:
    419
    Hello Barabicus,

    Yes that's a valid use of AMS. Baking scenes is one way to get around these issues but of course have advantages (e.g. execution order) and disadvantages (e.g. bloat your build).

    I would advise you to leave anything that is not order-dependent in Awake (e.g. caches for anything in your children) and anything that may be order dependent into Start (e.g. anything that accesses an object not in your children). This will give you more flexibility with how you decide to load scenes.

    Keep your "Main Scene" (e.g. the one that represents your level) as simple as possible, and instead rely on the AMS functionality to pull-in the other scenes. The order in which the scenes appear in the hierarchy matches the order they will be pulled in.

    Cheers.
     
  16. Barabicus

    Barabicus

    Joined:
    Jun 5, 2013
    Posts:
    158
    Hey Thanks for the reply Jodon. I actually ended up purchasing it and it completely solved my problem! I can't begin to tell you the hassle it was causing me previously.
     
  17. plockhartt17

    plockhartt17

    Joined:
    Nov 14, 2016
    Posts:
    10
    Don't know if this is a none requirement, but for the lazy googler like me;

    I had an issue where cross scene references weren't getting restored correctly upon runtime. If you have a cross scene reference that targets a gameobject that is one of many of the same name, it obviously will not find the correct one. Just make sure all are uniquely named!
     
    Jodon likes this.
  18. silentslack

    silentslack

    Joined:
    Apr 5, 2013
    Posts:
    268
    Hi,

    I'm making great use of this plugin and it really has helped team work together remotely, thanks.

    I'm not sure if this is something in my code, Unity code or AMS but I'm having a problem with all scenes being marked dirty every so often. This is a problem as scenes like Sfx/Music are being marked Dirty when I'm working on Gameplay scene and I'm then overwriting changes made by the Sfx developer.

    I can't quite pin down what action is causing it but I know that after about 20 mins all open scenes get marked as dirty. Just wondering if you've encountered this?

    Many thanks, Jake
     
  19. silentslack

    silentslack

    Joined:
    Apr 5, 2013
    Posts:
    268
    Hi,

    Regarding my previous question. I think one culprit is changes to RenderSettings but I'm sure there is also some other change which is setting all scenes dirty which is a bother.

    Anyhow, I have another question - Are you aware how well AMS plays with the Sectr Streaming system? I'm really after a decent occlusion system to help with performance but unsure if AMS and Sectr are compatible?

    Any info here would be much appreciated!

    Many thanks, Jake
     
    jdraper3 likes this.
  20. mr_blahblah

    mr_blahblah

    Joined:
    Jan 15, 2016
    Posts:
    25
    Hey, got a feature request - just an ease of us thing.

    Would it be possible to add a context menu to a game object in the hierarchy to go:

    Right Click Game Object in Hierarchy > 'Add as Multi-Scene' ?

    e.g. create a scene and populate the multiscene component with the right data
     
  21. haskins

    haskins

    Joined:
    Oct 11, 2013
    Posts:
    24
    Hello, is there a way to 'lock' a scene? For example if in the current scene I have 'Main', 'Sound', and 'Static objects' scenes in the hierarchy, and I want to ensure my sound guy doesn't accidentally edit 'Main' or 'Static object'. Hopefully it's there, and I'm overlooking something.. if not, man.. it would be a killer feature! Thanks for the time.
     
    nazbee likes this.
  22. Jodon

    Jodon

    Joined:
    Sep 12, 2010
    Posts:
    419
    Unfortunately not. I had this in the previous product (before Multi-Scene was added) and it caused a ton of headaches for a few people, so I decided to scrap it. If you're using source control, you always have the option of seeing what you've touched before you submit it. I always just revert any scenes I know I'm not supposed to be touching. This happens a lot for me too due to our use of NGUI. I'll see if I can re-implement it in the new Unity without introducing the slew of bugs associated with the functionality.

    If anyone wants this feature, please like his comment! :)

    Cheers.
     
  23. Jodon

    Jodon

    Joined:
    Sep 12, 2010
    Posts:
    419
    That's possible, but I wouldn't know where to create the scene in your Project, so you'd have to end up renaming/moving it when I do that. It's probably no faster than the current method:

    Right-click in the Project Window and you can create a new Scene Asset. Drag that Scene Asset into the Hierarchy Window then move the GameObject into that new Scene. When you save all of the references will be recorded and work as usual.

    Cheers.
     
  24. Jodon

    Jodon

    Joined:
    Sep 12, 2010
    Posts:
    419
    Hi Jake, I don't know if Sectr is compatible (I don't own Sectr). It would only work with this plug-in if Sectr uses Unity Scenes. Otherwise you would have to make sure the singletons end up in the Sectr sub-scenes (whatever format they use). After that, it should work properly.

    Cheers.
     
  25. haskins

    haskins

    Joined:
    Oct 11, 2013
    Posts:
    24
    Jordon, good to know on the scene locking, thanks for the reply.
     
  26. apprenticegc

    apprenticegc

    Joined:
    Apr 21, 2012
    Posts:
    7
    Hi,
    When Multi Scene is used with Full Inspector, there is always exception thrown from ResolveInternal in RuntimeCrossSceneReference.

    The step showing the exception is that if there is any game object with component deriving from FullInspector BaseBehavior inside any additional scene loaded with additive option, during the runtime, the exception is thrown.

    I am not sure if Multi Scene conflicts with Full Inspector or the other way around. Since Multi Scene works pretty well with my many other plugins, I am not quite sure if I should post the issue here.

    However if it doesn't bother you too much, hope you can help, thanks

    P.S. Full Inspector could be accessed from GitHub.
     
  27. Jodon

    Jodon

    Joined:
    Sep 12, 2010
    Posts:
    419
    Thanks for the GitHub link. I don't have the time to look at this today, perhaps on the weekend. What I've noticed is that lots of over plug-ins like storing things in serialized fields (maybe for convenience of exposing them in the UI), but they should not actually be serialized. If it ends up in the serialized list, then that's an issue that they're storing variables that way.

    Cheers.

     
  28. Jodon

    Jodon

    Joined:
    Sep 12, 2010
    Posts:
    419
    I've been able to reproduce this bug. There are a few ways we can fix this:

    1. First, you could simply filter out the offending types in PopulateReferenceMap. If ( typeof(OffendingType).IsAssignableFrom(obj) ) continue;
      • You could also see if the obj/component belongs to fiPersistentEditorStorage.SceneStorage and the other offending GameObjects.
    2. My issue ends up being in the Resolve code pertaining to a list, usually because there aren't enough items. You could try to edit this code instead of use IList.Add() though I'm kind of against this, as it may cause more issues due to changing list size invalidating other indices (though maybe it doesn't matter at this point since we've already deemed the index invalid). Search for "Expected collection of at least {0} elements from property {1}".
    3. Finally (and probably the most robust solution) is I can add an attribute you can put on your classes to deem them non-cross-referencable. We could add these to the Full Inspector source code on classes we know are just book keeping. This may also help other plug-ins become compatible when they're written to serialize data when they shouldn't.
    Take your pick and let me know how it turns out! If you go with #3 I can send you a new beta version.

    Cheers.
     
  29. cabrendan

    cabrendan

    Joined:
    Jan 10, 2013
    Posts:
    10
    Jodon,

    I've been having mixed results with Cross-scene references in PlayMaker FSMs. A simple example is reproducible by using the PlayMaker "EnableBehaviour" action. If I use the "Specify Game Object" flow, choosing a component type (serialized as a string), the cross-scene reference works. If I use the raw-component flow, drag and drop the component itself into a different field, the cross-scene reference fails. I am suspicious that a disagreement on the field's type is causing the cross-scene-reference tool to give up on assigning the value. PlayMaker action data seems to get packed into arrays, if that's useful.

    This is a pretty serious issue for the way I was intending to use AMS, since the majority of the PlayMaker FSMs are being used to detect changes and cause changes in many aspects of the world-state, and they can potentially reference any sort of thing in any of the other scenes.

    I'm including the relevant snippet from the scene's YAML storing the cross-scene-reference data:
    The first cross-scene-reference works (from the field: fsmOwnerDefaultParams), and the second one fails.
    _crossSceneReferences:
    - _fromObject:
    scene:
    editorAssetGUID: 203893c9c1caf86468ab4b8aabe3f910
    name: Core_PM
    _path: Assets/_GameScenes/TestAMS/Core_PM.unity
    fullPath: /PlayMakerFSM_Test
    componentName: PlayMakerFSM, PlayMaker, Version=1.6.0.0, Culture=neutral, PublicKeyToken=null
    componentIndex: 0
    editorLocalId: 0
    editorPrefabRelativePath:
    version: 1
    _fromField: fsm.states,0.actionData.fsmOwnerDefaultParams,0.gameObject.value
    _toObject:
    scene:
    editorAssetGUID: b07d32eab0bde1c419221ecb993bf96f
    name: Core_Refs
    _path: Assets/_GameScenes/TestAMS/Core_Refs.unity
    fullPath: /Spinner
    componentName:
    componentIndex: 0
    editorLocalId: 0
    editorPrefabRelativePath:
    version: 1
    - _fromObject:
    scene:
    editorAssetGUID: 203893c9c1caf86468ab4b8aabe3f910
    name: Core_PM
    _path: Assets/_GameScenes/TestAMS/Core_PM.unity
    fullPath: /PlayMakerFSM_Test (1)
    componentName: PlayMakerFSM, PlayMaker, Version=1.6.0.0, Culture=neutral, PublicKeyToken=null
    componentIndex: 0
    editorLocalId: 0
    editorPrefabRelativePath:
    version: 1
    _fromField: fsm.states,1.actionData.unityObjectParams,0
    _toObject:
    scene:
    editorAssetGUID: b07d32eab0bde1c419221ecb993bf96f
    name: Core_Refs
    _path: Assets/_GameScenes/TestAMS/Core_Refs.unity
    fullPath: /Spinner (1)
    componentName: TMPro.Examples.ObjectSpin, Assembly-CSharp, Version=0.0.0.0,
    Culture=neutral, PublicKeyToken=null
    componentIndex: 0
    editorLocalId: 0
    editorPrefabRelativePath:
    version: 1
    _realSceneRootsForPostBuild: []
    _mergedScenes: []
     
  30. cabrendan

    cabrendan

    Joined:
    Jan 10, 2013
    Posts:
    10
    With further investigation, I've discovered that references stored as FsmObject fields work just fine. It seems to be a problem with having the field directly store the type you want. So, this can be worked around with pervasive, but relatively easy changes to our custom FsmActions.
     
  31. Jodon

    Jodon

    Joined:
    Sep 12, 2010
    Posts:
    419
    If you send me a minimal repro case I can look into it. Either as PM here or e-mail the address in AMS' Documentation.txt file. I have a license for PlayMaker so I'll be able to load it. Cheers.
     
  32. cabrendan

    cabrendan

    Joined:
    Jan 10, 2013
    Posts:
    10
    Sent an email with a fairly minimal reproduction case.
     
  33. martaaay

    martaaay

    Joined:
    Apr 13, 2009
    Posts:
    136
    I'm having the classic cross scene reference race issue when loading the scene in the editor when using OnClientStart from unet. There's not a good way to push OnClientStart code later. But, is there some call that I can make to force the cross scene reference fixing to occur? (Using unity 5.5)

    Edit: To expand on this - because some NetworkIdentity objects aren't loaded on time, unet just disables them. I'm speculating this is only an editor issue since baking will happen at build time when creating an ios/android binary. If there's a way to cheat just for the editor, I'm willing to do that.
     
    Last edited: Mar 16, 2017
  34. Jodon

    Jodon

    Joined:
    Sep 12, 2010
    Posts:
    419
    If it's truly a race issue, I may now have a solution for this. The new beta should allow cross-scene references to occur during Awake()/OnEnable() as it will execute sooner. Send me an e-mail and I'll send you the beta build.

    It's worth noting that about 7 months ago I developed network functionality using multi-scene and additive scenes. I ran into a bunch of issues with Unity Networking that seemed to be growing pains (had nothing to do with my plug-in). It seems like their unique network ids are not updated when loading in other scenes. I would double-check they've fixed this first. You'll see this issue when network messages get routed to the wrong objects. Good luck.
     
  35. Jodon

    Jodon

    Joined:
    Sep 12, 2010
    Posts:
    419
    Sorry for the delay on this, as I wanted to explore all options. However, it doesn't look this is possible to do cleanly with their current setup. The problem is 'locking' a scene (setting Object.HideFlags to NotEditable) gets saved with the scene. This means when you load in a scene all objects will come in locked. There are too many edge cases to make this work robustly (e.g. you can add GameObjects to that scene regardless of if it's locked, you can have compilation errors when the scene loads preventing you from unlocking objects, etc.)

    To do it properly is too much effort, and I really want to avoid giving half-baked solutions. Sorry!
     
  36. nrvllrgrs

    nrvllrgrs

    Joined:
    Jan 12, 2010
    Posts:
    20
    Let's say I have scenes A and B, both of which are main scenes. These scenes both include scene C, which contains the streaming logic to move between A and B. Is it possible to unload scene A without unloading scene C?

    EDIT:
    Nevermind. I using LoadSceneMode.Single instead of LoadSceneMode.Additive in my streaming code. So you can unload A then load B using LoadSceneMode.Additive without losing C.
     
    Last edited: Mar 26, 2017
  37. hungrybelome

    hungrybelome

    Joined:
    Dec 31, 2014
    Posts:
    275
    Just to be clear, is it not a good idea to use Unet with this plugin at the moment?
     
  38. Jodon

    Jodon

    Joined:
    Sep 12, 2010
    Posts:
    419
    It's fine to use the plug-in, I've run into issues with Unity and multi-scenes (regardless of if the plug-in is used). Those may have been addressed by now as this was about a year ago. I'm very close to releasing the next version of the plug-in, you can e-mail me for a beta which addresses the cross-scene references not being available during Awake().
     
  39. HaakonL

    HaakonL

    Joined:
    Mar 13, 2014
    Posts:
    114
    Hey, we had to ditch Multi Scene today after weeks of weird lightmapping issues. For example, when building lightmaps in Level X, the Lightmap Data Asset for some other Level (the scene previously opened probably) would be deleted. All our levels used AMS to include a shared scene, and it was set to Baked.

    Another issue we have seen is that even though it looks like the lightmaps are loaded in the editor, after switching between scenes and coming back the lightmaps where not loaded after all.

    Once we removed AMS all the issues stopped occuring. Using 5.6.0p1, but we have had issues with this for several months, also in 5.5.x and all of the 5.6 betas.
     
  40. Jodon

    Jodon

    Joined:
    Sep 12, 2010
    Posts:
    419
    You need to make sure none of the other scenes are open when using Baked lightmaps. When you Bake lightmaps, the Lightmap Data Asset is shared between all opened scenes for whatever you just baked.

    This is mostly likely a Unity bug (seen this happen often). If you're able to reproduce it by simply dragging in another scene and hitting play (then reloading that scene via a script that does LoadScene) it's definitely Unity's issue.
     
  41. Klarax

    Klarax

    Joined:
    Dec 2, 2013
    Posts:
    17
    This asset does not work well - at all - its very temperamental and very buggy.

    Saving a single asset reference across a scene works 60% of the time. Arrays do not work correctly at all if you ask me.

    You can set things up perfectly, and may even work for a bit, and then at random, you save game, then boom; Asset spams console with errors relating to mismatch type, and empty every single one of your arrays from a script, and sometimes even single asset refernces.

    So you set everything up (and in a professional project will take hours), for it to work for a bit before doing exactly the same thing!

    At it's current state - its not worth 5 bucks let alone the asking price.

    Honestly, I don't think this asset will be fixed so its stops this issue, and if no fix is released within 2 weeks of this date. I will be reviewing it 1 star on the store with these comments above!

     
    Last edited: May 5, 2017
  42. Jodon

    Jodon

    Joined:
    Sep 12, 2010
    Posts:
    419
    Hey Klarax, sorry you're having issues with the asset. In the log you posted, is the scene "Stuff Cant Turn Off" loaded? Are those objects still around, or have they been deleted? What are its load settings set as (baked, additive, etc.) Is this during a save, during a build, or during a play? Can you send me the log file, so I can see the warnings and any errors that can occur before this? There are hundreds of users using this asset, and the only issues that have been reported are ones that occur due to other plug-ins.

    Cheers.
     
  43. michaelwolf95

    michaelwolf95

    Joined:
    Oct 16, 2015
    Posts:
    4
    This is for anyone out there googling this issue:

    Read the Documentation. It's very well written.
    I wasted a lot of time today trying to figure this stuff out, when I could have just read the doc.

    I was having the same issue as HaakonL - Lightbaking one scene would override another - and I noticed that I had one sub-scene in common between the two. I was able to resolve the issue simply by unloading the scene in both of them and rerunning a lightbake. This is explained in the doc.
     
    Jodon likes this.
  44. Egil-Sandfeld

    Egil-Sandfeld

    Joined:
    Oct 8, 2012
    Posts:
    54
    I'm just dropping by to say I'm so pleased with using this asset! Just started using it now, but can surely see a lot of time and headaches being saved from now on :)
     
    Jodon likes this.
  45. mr_zog

    mr_zog

    Joined:
    Jan 21, 2014
    Posts:
    165
    Hi!

    Bought the asset today and evaluating the workflow with it.
    The main reason I wanna use it are cross scene references.
    I read through the docs carefully, but I didn't get them to work: Always got the error (see image also):
    errors.jpg

    Code (csharp):
    1.  
    2. Ams Plugin: Restoring Cross-Scene Reference MainLogic (ModernAlchemists.ObjRefs).skipBtn => Dev Split Main'/MainCanvas/DemoStepCtn/SkipBtn' (UnityEngine.UI.Button #0)
    3. AmsCrossSceneReferences in Dev Split Logic: Cross-Scene Ref: MainLogic (ModernAlchemists.ObjRefs).skipBtn => Dev Split Main'/MainCanvas/DemoStepCtn/SkipBtn' (UnityEngine.UI.Button #0). Could not Resolve toObject
    4.  
    Now luckily, I found out what was causing the error: The object holding the source objects has a DontDestroyOnLoad enabled like so:

    Code (csharp):
    1.  
    2.     public class DontDestroyOnLoad : MonoBehaviour
    3.     {
    4.         void Awake()
    5.         {
    6.             if( this.transform.parent == null )
    7.             {
    8.                 DontDestroyOnLoad( this.gameObject );
    9.             }
    10.             else
    11.             {
    12.                 Debug.LogWarning( string.Format( "DontDestroyOnLoad only works on root-game-objects (name='{0}.{1}')", this.transform.parent.name, this.name ) );
    13.             }
    14.         }
    15.     }
    16.  

    As soon as I removed this component, it seems to work.

    Now I am wondererd: Searching out codebase for DontDestroyOnLoad, I see that some 3rd party extensions (e.g. NodeCanvas, I2Localize) use this aswell.
    Are we to expect trouble with that some time down the road?
    Is this only troublesome, if you try to cross-reference variables/objects with DDOL?

    errors.jpg


    Thanks!
     
  46. Jodon

    Jodon

    Joined:
    Sep 12, 2010
    Posts:
    419
    Hello Mr. Zog,

    It appears Unity may be changing what "Scene" the GameObject is in once set to DontDestroyOnLoad. This could be playing havoc with the cross-scene reference resolving. It seems really weird that it's failing on resolving the "toObject" (which means the destination rather than the source). You are saying the source is the DDOL right? I think it would be an easy fix, and I'll cover this case in an update and send you an early release. Send me an e-mail to remind me to do this.

    If you want to send me a minimal repro case that'd save me some time in case it's something else going on. If it's just a matter of throwing that MonoBehaviour on a Source Object that'd be easy to do.

    Thanks for the bug report!
     
  47. Ben-BearFish

    Ben-BearFish

    Joined:
    Sep 6, 2011
    Posts:
    1,183
    @Jodon We seem to be having an issue building to the HoloLens with your plugin in our Assets folder. Do you know a fix for this? Are there issues building to Windows UWP apps with this plugin?
     
  48. Jodon

    Jodon

    Joined:
    Sep 12, 2010
    Posts:
    419
    It looks like I broke it in my last update. Try this fix:

    In GameObjectEx add these two lines:

    Code (CSharp):
    1. // Needed for UWP
    2. using System.Reflection;
    3. using System.Linq;
    Change this method:

    Code (CSharp):
    1.         static GameObjectEx()
    2.         {
    3. #if NETFX_CORE
    4.             s_GetRootGameObjectsInternal = typeof(Scene).GetTypeInfo().DeclaredMethods.FirstOrDefault( x => x.Name == "GetRootGameObjectsInternal");
    5. #else
    6.             s_GetRootGameObjectsInternal = typeof(Scene).GetMethod( "GetRootGameObjectsInternal", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic );
    7. #endif
    8.         }
    9.  
    Let me know if that works or doesn't. I can't get UWP to run at the moment (I didn't install VS2017).
     
  49. mr_zog

    mr_zog

    Joined:
    Jan 21, 2014
    Posts:
    165
    Hi,

    here's a repo project:
    http://slegg.net/MultiSceneTest.zip

    Just 2 scenes with 2 objects referencing each other.
    The sphere has the DontDestroyOnLoad component attached.

    If you play, it doesnt work.
    If you remove the DontDestroyOnLoad component, it works.
     
  50. Jodon

    Jodon

    Joined:
    Sep 12, 2010
    Posts:
    419
    Hi Mr. Zog,

    I highly recommend avoiding cross-referencing to a DontDestroyOnLoad object. If you're setting something to DDOL that's an indication it's a manager that needs to act like a Singleton across levels, and you can follow a singleton or MonoSingleton sort of pattern for it (a lot are available on the web).

    Having said that, it does disturb me that other people's plug-ins could attempt a cross-reference to a DDOL object so I've decided to try and fix this in my plug-in. It now passes this new test case, but warns you since this is probably unintended. To fix this, find RuntimeResolve and change the code around FindBySceneAndPath to this:

    Code (CSharp):
    1.             // Try to find the Object with our custom method that checks only the subscene
    2.             GameObject gameObject = GameObjectEx.FindBySceneAndPath( scene, fullPath );
    3.  
    4.             // If that fails, we can try using Unity's GameObject.Find in case the user has switched it on us, or
    5.             // in the case that's it's in a DontDestroyOnLoad scene
    6.             if ( !gameObject )
    7.             {
    8.                 gameObject = GameObject.Find( fullPath );
    9.  
    10.                 // It's truly failed
    11.                 if ( !gameObject )
    12.                     return null;
    13.                 else
    14.                     AmsDebug.LogWarning( gameObject, "UniqueObject '{0}' resolved unexpected to '{1}'{2}.  Did you move it manually?", this, gameObject.scene.name, gameObject.GetFullName() );
    15.             }
    You can of course remove the warning portion if you intend to continue to use it this way. The next version will contain the warning.

    Cheers.