A Unity ID allows you to buy and/or subscribe to Unity products and services, shop in the Asset Store and participate
in the Unity community.
Discussion in 'Assets and Asset Store' started by Jodon, Feb 2, 2016.
we have a big issue with AMS.
In case we have compiling error in editor and we hit "play", after that AMS lose all the references from the other scene.
Before to click save, if we check di AMS game object, the reference path and object is still filled in the component, but the component itself will be empty.
Can you reproduce?
Yes I can reproduce this issue and it has plagued me for a while. In Unity 5.6 you can fix this issue quite easily. In AmsPlaymodeHandler.cs, introduce the following code within the #if:
EditorApplication.playmodeStateChanged += () =>
if ( EditorUtility.scriptCompilationFailed )
AmsDebug.Log( null, "Skipping cross-scene references due to compilation errors" );
if ( !EditorApplication.isPlaying && EditorApplication.isPlayingOrWillChangePlaymode )
I am looking at a work-around for older versions. I will release an update as soon as I have something suitable. Thanks for tracking down this bug.
Any plans on AMS handling the cross-scene references and bindings in Timeline? The point being to be able to run cutscenes in a different sub-scene.
I haven't looked at this yet. I believe the issue is they're using structs throughout the Timeline as opposed to classes, which makes the assignment portion of reflection not work (it's not implemented in Mono 2.x for structs). There may be a work-around if Unity 2017 contains a new Mono runtime. If you send me an example, I will certainly give it a shot.
Attached is a project made in 2017.1.0f3. It uses Cinemachine because it has Binding and ExposedReference in their Playable system, but you could reproduce the Binding issue with a simple cube reference in another scene.
In the screenshots, I have highlighted in red the references that are lost in a MultiScene scenario:
Bindings on the Playable Director
ExposedReferences on Timeline Clips (here Cinemachine Shot Clip)
Thank you for your time.
Unfortunately they have completely mucked up how they're storing references in the Playables system. It looks like they are trying to support some kind of assets to scene references, and as a result none of the variables that we need to modify are exposed. For this reason, I can't support it easily. I will look into expanding AMS to support custom-serialized systems in the future, but we're looking at 2 weeks+ down the line.
I would love to buy the internal level map / portal editor, any chance that this will be released?
It just what unity is missing
It's a year or more old at this point and the title it was being for is no longer in development.
l doubt I'll ever release it publicly. If you are still interested, send me a pm or an email. Let's not hijack the op's thread.
does your plugin work in 2017.1.2?
Yes, it works in everything up to the latest (2017.2.0p4). There are a couple of warnings when compiled with the latest, but everything works as designed. Hoping to get an update out to get rid of warnings and Timeline support by Christmas.
Using AMS to unload and load Scene levels is there some documentation on scripting AMS update One scene from Additive to Don't Load, and another to Additive or do I just use scene manager and AMS will understand the scene change?
I would be great if you could access the AMS code directly and load scenes via script.
Is there any callback API to AMS?
I guess what I want is Method Function documentation
There is no documented way to call into AMS to load or unload scenes. The functionality is meant to work transparently, and without any necessary modification to your existing code. You can use the built-in Unity functionality as usual to load a desired scene. AMS will then automatically pull in any of that scene's dependencies (as configured in the Editor). It will also automatically resolve the cross-scene references. The unloading of a scene is also done through the built-in Unity functionality. Remember that unloading a scene can cause cross-scene references to become invalid.
In the current state it's not unusable in any average size project.
I try to split my project during two days -> it doesn't work.
- If Scene are not added with a drag and drop, it doesn't detect it (and don't add it in the amsMultiSceneSetup). You should make it explicit in the tutorial.
- I don't understand why you can't have two objects with the same name. Maybe you should use the instanceId which should be unique instead of the object name (or a combination of scene name + instanceID as a Key). This is the way unity work, and user should be able to do it.
- It make unity crash often.
- Some cross scene reference are just not working. A canvas can't link to a camera in another scene. Don't know why.
So a lot of problems, that make it usable.
I use this plug-in every day, and it's been integral into a project that's been in development for over four years. We typically have around 130 cross-scene references per 'main scene'. I assure you this is intended for an average to large size project. Let's try to solve your problems (I've re-formatted with numbers for a better response):
How else are you trying to add a scene? The AmsMultiSceneSetup is added during the save phase (it's not important it gets added immediately).
This is something I intended to look at, but unfortunately anything I do may break compatibility. The problem is InstanceID does not persist across scene loads. The re-linking needs to be done at runtime, and searching by name is the only fast / efficient / safe method at the moment.
What version of Unity are you running, and are you 100% sure it's this plug-in? As I've said, it's in use every day on 5.6.4p4 and had been used for about 3 months on 2017.2.0p4. We hadn't seen any crashes attributed to the plug-in. Can you send me the Editor.log of a crash that's caused by the plug-in?
There are cases right now where (recently) Unity has tried to hide the serialized properties from runtime access and that will break the cross-scene references. It appears Canvas is one of those cases, where you would have to access the Canvas.camera property to set the camera, but the actual underlying property is Canvas.m_Camera. This is similar to Cinemachine / Timeline which also does not work at the moment. A couple of quick fixes for this:
Use the Camera in the same scene (ensure your UI is bundled together in one scene as much as possible).
Write a custom MonoBehaviour called CameraSetter which contains the Camera (_savedCamera) you want to link to. This MonoBehaviour can just call Canvas.camera = _savedCamera;. This will allow the cross-scene referencing to work, as it will be saved in this MonoBehaviour.
1. Right click in project add scene. It doesn't refresh (the main scene don't have any of the scene added to the list)
2. I understand the problem. Did you ask Unity to have access to it ?
(If you save data with version, there is no reason to break anything when you need to change the format. Adding an update format is quick and safe)
3. 2017.3, it seems you're doing something during save that freeze and crash unity.
4. 1. not possible as we want to work on two part of the UI which both use the same camera.
2. that's what I did.
Also it loses cross reference sometimes (error message cross reference not found during runtime). I had to move the object with the lost cross reference to another scene, save scene, and move it back to fix it.
PS: you use it everyday but it's for your project, your structure, the way you click and add object, and can't adapt right now to other game workflow/structur
PS2 : I work with another coder and he gave up a lot sooner than me.
PS3: Sorry of being harsh, it just I was disappointed
We're going to port one of our Google Cardboard games over to Vive for the Global Game Jam this weekend. It makes extensive use of this plug-in and we'll make sure to upgrade to 2017.3 (latest patch) or 2018.1. I'll fix any issues I encounter such as #1 and #3. However, if you're not on the latest 2017.3 patch, please upgrade to it. Particularly this bug might be what you're experiencing:
(967206) - Scripting Upgrade: Fixed random crash due to memory corruption on domain reload.
#2 Unfortunately I'm fairly confident Unity doesn't save this information. In the Editor they use GUID's so it's always possible to relink properly. Once an export happens, I'm fairly sure that data is gone and inaccessible at runtime (and replaced with InstanceIDs). My guess is they go through a process during export/play-in-editor to 'convert them over', but that's where this issue comes in: You can link to another scene which is not loaded during the export / play-in-editor phase, so it has no chance to re-link it (unlike the single scene case). I solved this in the previous product (Advanced Additive Scenes for Unity 4.x) by generating GUIDs and storing them in the target scene, but that forced both the source and target scene to dirty during any cross-scene edits and people hated that. I've been working on this problem for over 4 years, and the naming + editor GUID is a fairly robust solution all things considered.
I know this is super late, and I'm sorry about that. But I have decided to start tackling this issue. I think I have a solution that's ready for testing. Please let me know if you're still interested in a version that solves this. Anyone else reading, if you're looking for cross-scene referencing in Timeline / Cinemachine / Playables, please send me a direct message and I'll get you a beta version.
The team and I have been using this tool since August 2017 and it has been a god save. Just recently we started running into issues with the tool where we lose some references after a collab. (Which can be said for everything) But ignoring the issues with collab we have been having a different problem. I am not sure if this is a check or if there is actually a problem with the reference, but we have been getting errors since 2017.3.0f3 that i think are just debug errors because the underlying references work fine in game. I was looking at your source code and it could be a timing issue where the object is not quite resolved after the scene is loaded. I have attached an error that may help, but these errors are thrown after loading a scene in the editor and in-game.
I think (hope) what's going on is that a stale cross-scene reference has been lingering in your cross-scene references. The stale reference probably has a duplicate (proper) reference. Let's see if that's the case:
Check the ! AmsMultiSceneSetup object in your scene, and look at the cross-scene references. Expand them and see if there's one that goes from a null (missing) source object. Hopefully there will be a second one that has the same destination, but a valid source object. You can right-click to delete the invalid source one.
New version of the plug-in has been released. It covers the majority of cases where Unity has not exposed properties that are cross-scene referenced including the UI system and Timeline / Cinemachine. Let me know if you use those features!
Hello this is just what I was looking for but I'm stuck with unity 3d 5.5.4. Will this work with most of the functionality? If thing will not work could you please list what may not work? I noticed you started this with 5.3. Hopefully this still works, Thanks for your feed back.
Yes, most of the functionality will work. Cinemachine and Timeline are only introduced for 2017, which has been the most recent update. I've just submitted another package with 5.4+ support, which will alleviate the compilation errors you'd receive with 5.5.4. Judging by the previous times asset store approval times, it should be available tomorrow.
Jodon you are the man thanks for that update. Buying this asap, thanks again.
Hello! this is a great way to bypass the 4gb resS file issue with Unity too.. Perfect.
Where can I find detailed docs?
Hi Jodon and thanks for a great asset!
I have an issue with my project. When I start play in Editor or save the project, the following appears in the console:
The same field name is serialized multiple times in the class or its parent class. This is not supported: Base(MonoBehaviour) m_GameObject
CodingJar.MultiScene.Editor.AmsCrossSceneReferenceProcessoropulateReferenceMap(List`1, IEnumerable`1) (at Assets/CodingJar/MultiScene/Editor/AmsCrossSceneReferenceProcessor.cs:123)
CodingJar.MultiScene.Editor.AmsCrossSceneReferenceProcessor:UpdateReferencesMap() (at Assets/CodingJar/MultiScene/Editor/AmsCrossSceneReferenceProcessor.cs:90)
CodingJar.MultiScene.Editor.AmsCrossSceneReferenceProcessor:ComputeAllCrossSceneReferences() (at Assets/CodingJar/MultiScene/Editor/AmsCrossSceneReferenceProcessor.cs:50)
CodingJar.MultiScene.Editor.AmsCrossSceneReferenceProcessor:GetCrossSceneReferencesForScenes(IEnumerable`1) (at Assets/CodingJar/MultiScene/Editor/AmsCrossSceneReferenceProcessor.cs:57)
CodingJar.MultiScene.Editor.AmsSaveProcessor:HandleCrossSceneReferences(IList`1) (at Assets/CodingJar/MultiScene/Editor/AmsSaveProcessor.cs:93)
CodingJar.MultiScene.Editor.AmsSaveProcessor:OnWillSaveAssets(String) (at Assets/CodingJar/MultiScene/Editor/AmsSaveProcessor.cs:47)
UnityEditor.AssetModificationProcessorInternal:OnWillSaveAssets(String, String&, String&, Int32)
I store data in some scriptable objects and can manage to save, load, reset these during runtime and during design time. I don't think it's a big issue as I can play the scene fine with all cross-scene references working afaik.
Forcing a "Detect Cross-Scene Ref" does not solve the issue.
Maybe the issue is not on your end at all, I just don't understand the error it is giving me.
Thanks in advance
It sounds like you have written a MonoBehaviour that has a public or serializable field called either gameObject, or m_GameObject. The error is complaining that you can't do that, because MonoBehaviour already serializes that field.
Thanks for replying, Jodon
These are my search results in my entire solution for public Gameobject or anything that's called m_GameObject:
As you can see there is nothing called m_GameObject, nor is there a public GameObject gameObject.
Should I try removing AMS?
After a few days of seeing this issue, I've pushed to git and changed a few things on another computer, came back to this computer and pulled. The error has disappeared, so I guess it was just fun little shenanigans =)
Thanks again for the help and an awesome asset!
We've been using AMS for a while. We have it set to "bake" scenes together when we build the player - and our understanding is that this merges the scenes together in the build so that only a single scene is loaded at runtime (saving the overhead of additively loading multiple scenes). Is that a correct assumption? Where in the current pipeline are the scenes baked by AMS?
We are in the process of switching over to using Asset Bundles. In order to use Asset Bundles effectively, we aren't including all our scenes in the Build Settings. Instead we load a small master scene, asynchronously load asset bundles containing scenes and assets, and then load and launch them. In this case, am I right to assume that AMS will NOT 'bake' scenes together in the same way as before?
Hope this is clear, it's hard to get my head around! Thanks
EDIT: After posting this, I realised I could enable verbose debugging, and discovered that AMS does still merge the scenes as expected when building asset bundles. I presume the PostProcessScene callback is still called by Unity when building bundles. So looks like everything can work the same. Great!
Excellent. I haven't done much work with Asset Bundles yet, let me know if you run into any issues that I can help with. It appears like you've tracked down the answer to the original question, we merge during a PostProcessScene step. There's also a pseudo-merge in AmsMultiSceneSetup if you play the active scene (PostProcessScene doesn't run early enough when playing the active scene).
Hey there. It seems the tool does not work for unity 2018 for the playable director. I know for sure it works on 2017, but something must have changed on the transition. Will the tool be supported for the 2018 version of unity?
Sorry for the late reply BTW. Your solution worked. Also it seems when it happened again fixing it involved me just changing the reference to none type, saving, then placing again what was needed from the object picker.
Hello Bubsavvy, Yes we will be supporting 2018. Unfortunately I'm just on a business trip at the moment, but you can expect support for this in about 8 days time. In the meantime, if you'd like to send me a small repro case I can see if I can get you a faster work-around. Cheers.
I just submitted an update for 2018. If you're desperate, the major change is I had #if UNITY_2017 in a lot of places, which has been switched to #if UNITY_2017_1_OR_NEWER. There's some additional fixes for Cinemachine and saving multiple self-referential scenes. Should be on the store shortly. Cheers.
Does this include a fix for timeline?
Yes. Let me know if anything does not work. I have only tested with Cinemachine and cross-referencing the Playables, Brain, and virtual cameras.
We're having an issue with AMS and saving a prefab.
We have a prefab instance on the scene with some public field that points to an object in a different scene. The issue is that when we save the prefab, the reference on the instantiated prefab is lost and reset to null.
I checked regular Unity behavior and if you have a prefab instance pointing to an object outside of the prefab, then after saving it the reference on the instance is not lost.
It's becoming problematic for us - are you able to change it so that the reference would not be lost?
I believe the issue is that you may be applying the prefab on the object that has a cross-scene reference. Unity does not support cross-scene references (hence the plug-in). If you click apply on a prefab that does not have this cross-scene reference, then manually change the instance it should save properly. That's because Unity only saves the changed data in the scene, and assumes that if there's no changed data it will take the prefab data (which is null since Unity does not support it natively). So in short: Quick work-around should be to hit the apply button on a prefab instance that does not have a cross-scene reference. If you send me a small repro case, I will fix it in a future release.
Thank you for a quick reply Jodon.
I did as you suggested - placed a second instance of the prefab on the scene, did not set a cross scene reference on it, modified it and applied the prefab. This however did not work as you described - the initial instance (with cross scene reference) got it's crosscene reference field nullified as before.
Do you have any other ideas?
Prefab instances save the differences between the original prefab and the instance in your scene. Try this: Drag the prefab into the scene, do your changes. Hit apply. Delete that prefab instance. Go to the one with the cross-scene reference, and hook it up again. Save the scene.
Now every time you edit the prefab, always use a 'fresh' instance (drag from the Project folder into the scene, changes, hit apply). Are you still losing the reference this way? Does the lost reference persist into playmode, or only in the Editor? It could be that you're losing it in the Editor but the plug-in correctly recovers it on a scene reload or on a play.
Let me know what version of Unity you're using and I'll track it down and patch it.
I am having similar issues with prefabs. Unity Version 2018.1.3f1. This has been occurring after a single run the references seem to be removed at the end of the run or after being in playmode.
Can you send me a repro case? This is often an indication of a null reference during initialization (or teardown). I think I've encountered one in the new Cinemachine code. Here's a patch for that if you're hitting it:
static bool HandleCrossSceneReference( RuntimeCrossSceneReference xRef )
MonoBehaviour cinemachineBehaviour = xRef.fromObject as MonoBehaviour;
if ( !cinemachineBehaviour || !cinemachineBehaviour.isActiveAndEnabled )
var type = cinemachineBehaviour.GetType();
string @namespace = type.Namespace;
if ( string.IsNullOrEmpty( @namespace ) || !@namespace.StartsWith( "Cinemachine" ) )
Thank you for the reply Jodon.
I did as you suggested and after applying changes to a separate instance of prefab the issue did not occur. However, after I tried to recreate it with original instance it did not occur as well. So either going through the pipeline that you suggested fixed it or it is after all a random issue. I will keep an eye on it in following days.
We're using Unity 2017.4.0f1.
I haven't had time to get back to you yet, but the Custom Resolver for Director has been working magic. Thanks a lot!
I have one custom change that we made to UniqueObjectEditorEx.cs that could be interesting to you, basically removing the assembly version number in the assembly name, which proved different from some PCs to other PCs.
componentName = obj.GetType().AssemblyQualifiedName;
gameObject.GetComponents( obj.GetType(), _reusableComponentsList );
componentIndex = _reusableComponentsList.IndexOf( comp );
// Removed Assembly version # from AMS component name.
var qualifiedName = obj.GetType().AssemblyQualifiedName;
var qualifiedNameSplitted = qualifiedName.Split(',');
string fixedQualifiedName = qualifiedNameSplitted + "," + qualifiedNameSplitted;
componentName = fixedQualifiedName;
gameObject.GetComponents( obj.GetType(), _reusableComponentsList );
componentIndex = _reusableComponentsList.IndexOf( comp );
In AmsCinemachineResolver::HandleCrossSceneReference, you should add a null check to the Namespace to support non-namespaced behaviours.
if ( !cinemachineBehaviour.GetType().Namespace.StartsWith( "Cinemachine" ) )
var Namespace = cinemachineBehaviour.GetType().Namespace;
if ( !Namespace.StartsWith( "Cinemachine" ) )
we're getting warnings when building the game similar to this:
The _REFERENCE_ above points to a cross-scene reference that is properly set and works when we play the game from editor or player.
Can you explain what the warning is about, since the game works fine? How can we get rid of it to have clearer build log?
I believe Unity warns about these differently based on Unity version, as I have seen it myself on newer builds. I'll look into it, but you can safely ignore them for now.
For example I have SEGI in one of my scene and I have directional light in another scene! Can I drag that directional light to SEGI script with this asset?
Yes, you can make the connection across scenes. However, I don't know anything about SEGI but a quick search shows this is a third party asset. If it relies on that connection being there before it initializes (Awake/OnEnable) then your scene that is connected must be baked together with that scene (the plug-in handles this), or it must be loaded before the SEGI scene so the light exists.
Great tool! I was wondering if there is any way you could provide us some sort of hook when you populate references. We use this tool heavily for our Quest System and would like to internalize it by saving the references to a file and using the editor tool to create a wizard for quest building. What we need access to is the map that you build when populating these references as well or perhaps an instance of one where we can add our own references according to whatever your parameters are (I am assuming the from Scene, to Scene, and path to ref). The main reason we need the hook is so whenever a scene is loaded we can populate the references we have stored in the file as a serialize map or array as opposed to using the in component solution. Does this make sense? Let me know if I need to clarify.
Thanks From TrollHouseGames.