MARS and ARFoundation Versions

Hi, the MARS docs say that it recommends ARFoundation version 2.1.8 but that it will work with higher versions. I need to have installed at least v3.1.3 of ARFoundation for other parts of my project to work. However, when these are installed, I get a ton of errors and nothing works in MARS:

UnityException: Transform child out of bounds
Unity.XRTools.Utils.GameObjectUtils.CopyHideFlagsRecursively (UnityEngine.GameObject copyFrom, UnityEngine.GameObject copyTo) (at Library/PackageCache/com.unity.xrtools.utils@1.0.1/Runtime/GameObjectUtils.cs:141)
MissingReferenceException: The object of type 'Camera' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.
UnityEngine.Camera.get_scene () <0x18b825280 + 0x00062> in <5fd17facc1814c7eab3a17c3c6136f31>:0
Unity.MARS.SimulationView.OnGUI () (at Library/PackageCache/com.unity.mars@1.0.2/Editor/Scripts/Simulation/SimulationView.cs:518)

How can I get MARS to work with later versions of ARFoundation? Is there some magical dependency chain? I’m also using ARKit XR Plugin 3.1.3 and FaceTracking 3.1.3 which won’t work unless they are the same version as ARFoundation it appears.

Need to get MARS working in my project. Thanks!

hello @scrant

MARS would work with 3.1.3, you just need to make sure that all the verions are set to the same (ARFoundation, ARCore/ARKit) About MARS AR Foundation Providers | MARS AR Foundation Providers | 1.0.2 hope this helps!

Hi @jmunozarUTech

This doesn’t seem to be working. ALL version of ARFoundation, ARKit, ARCore, and ARSubsystems are all set to 3.1.3 and yet… MARS completely freaks out. The Sim and Device views empty out and I get the above errors listed dozens to hundreds of times. In addition, the hierarchy has extra nodes added labeled “DELETE ME | temporary root used by SimulatedObjectsManager(Clone)” This happens in the template scenes as well.

Any other suggestions?

Which version of Unity are you using?.

Does the same happens if you create an empty project with ARFoundation, ARCore/Kit and AR Subsystems on 3.1.3?

Full error thread for the deleted camera object:

MissingReferenceException: The object of type 'Camera' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.
UnityEngine.Camera.get_scene () <0x161fc1ed0 + 0x00062> in <5fd17facc1814c7eab3a17c3c6136f31>:0
Unity.MARS.SimulationView.OnGUI () (at Library/PackageCache/com.unity.mars@1.0.2/Editor/Scripts/Simulation/SimulationView.cs:518)
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <437ba245d8404784b9fbab9b439ac908>:0)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <437ba245d8404784b9fbab9b439ac908>:0)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <437ba245d8404784b9fbab9b439ac908>:0)
UnityEditor.HostView.Invoke (System.String methodName, System.Object obj) (at /Users/builduser/buildslave/unity/build/Editor/Mono/HostView.cs:381)
UnityEditor.HostView.Invoke (System.String methodName) (at /Users/builduser/buildslave/unity/build/Editor/Mono/HostView.cs:375)
UnityEditor.HostView.InvokeOnGUI (UnityEngine.Rect onGUIPosition, UnityEngine.Rect viewRect) (at /Users/builduser/buildslave/unity/build/Editor/Mono/HostView.cs:351)
UnityEditor.DockArea.DrawView (UnityEngine.Rect viewRect, UnityEngine.Rect dockAreaRect) (at /Users/builduser/buildslave/unity/build/Editor/Mono/GUI/DockArea.cs:406)
UnityEditor.DockArea.OldOnGUI () (at /Users/builduser/buildslave/unity/build/Editor/Mono/GUI/DockArea.cs:395)
UnityEngine.UIElements.IMGUIContainer.DoOnGUI (UnityEngine.Event evt, UnityEngine.Matrix4x4 parentTransform, UnityEngine.Rect clippingRect, System.Boolean isComputingLayout, UnityEngine.Rect layoutSize, System.Action onGUIHandler, System.Boolean canAffectFocus) (at /Users/builduser/buildslave/unity/build/Modules/UIElements/IMGUIContainer.cs:293)
UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, UnityEngine.Matrix4x4 worldTransform, UnityEngine.Rect clippingRect, System.Action onGUIHandler, System.Boolean canAffectFocus) (at /Users/builduser/buildslave/unity/build/Modules/UIElements/IMGUIContainer.cs:508)
UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, System.Action onGUIHandler, System.Boolean canAffectFocus) (at /Users/builduser/buildslave/unity/build/Modules/UIElements/IMGUIContainer.cs:491)
UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, System.Boolean canAffectFocus) (at /Users/builduser/buildslave/unity/build/Modules/UIElements/IMGUIContainer.cs:484)
UnityEngine.UIElements.IMGUIContainer.SendEventToIMGUI (UnityEngine.UIElements.EventBase evt, System.Boolean canAffectFocus) (at /Users/builduser/buildslave/unity/build/Modules/UIElements/IMGUIContainer.cs:477)
UnityEngine.UIElements.IMGUIContainer.HandleEvent (UnityEngine.UIElements.EventBase evt) (at /Users/builduser/buildslave/unity/build/Modules/UIElements/IMGUIContainer.cs:449)
UnityEngine.UIElements.EventDispatchUtilities.PropagateEvent (UnityEngine.UIElements.EventBase evt) (at /Users/builduser/buildslave/unity/build/Modules/UIElements/Events/IEventDispatchingStrategy.cs:81)
UnityEngine.UIElements.MouseEventDispatchingStrategy.DispatchEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at /Users/builduser/buildslave/unity/build/Modules/UIElements/Events/MouseEventDispatchingStrategy.cs:69)
UnityEngine.UIElements.EventDispatcher.ApplyDispatchingStrategies (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel, System.Boolean imguiEventIsInitiallyUsed) (at /Users/builduser/buildslave/unity/build/Modules/UIElements/EventDispatcher.cs:310)
UnityEngine.UIElements.EventDispatcher.ProcessEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at /Users/builduser/buildslave/unity/build/Modules/UIElements/EventDispatcher.cs:275)
UnityEngine.UIElements.EventDispatcher.ProcessEventQueue () (at /Users/builduser/buildslave/unity/build/Modules/UIElements/EventDispatcher.cs:238)
UnityEngine.UIElements.EventDispatcher.OpenGate () (at /Users/builduser/buildslave/unity/build/Modules/UIElements/EventDispatcher.cs:203)
UnityEngine.UIElements.EventDispatcherGate.Dispose () (at /Users/builduser/buildslave/unity/build/Modules/UIElements/EventDispatcher.cs:44)
UnityEngine.UIElements.EventDispatcher.ProcessEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at /Users/builduser/buildslave/unity/build/Modules/UIElements/EventDispatcher.cs:301)
UnityEngine.UIElements.EventDispatcher.Dispatch (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel, UnityEngine.UIElements.DispatchMode dispatchMode) (at /Users/builduser/buildslave/unity/build/Modules/UIElements/EventDispatcher.cs:159)
UnityEngine.UIElements.BaseVisualElementPanel.SendEvent (UnityEngine.UIElements.EventBase e, UnityEngine.UIElements.DispatchMode dispatchMode) (at /Users/builduser/buildslave/unity/build/Modules/UIElements/Panel.cs:257)
UnityEngine.UIElements.UIElementsUtility.DoDispatch (UnityEngine.UIElements.BaseVisualElementPanel panel) (at /Users/builduser/buildslave/unity/build/Modules/UIElements/UIElementsUtility.bindings.cs:404)
UnityEngine.UIElements.UIElementsUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at /Users/builduser/buildslave/unity/build/Modules/UIElements/UIElementsUtility.bindings.cs:194)
UnityEngine.GUIUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at /Users/builduser/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:197)

Using Unity 2019.3.15f1

Can you please post what does the build settings check says?, Again, do you get the same errors if you create an empty project with ARFoundation, ARCore/Kit and AR Subsystems on 3.1.3?

OK, took me a few to setup a new test scene with all the packages. Sooo… a new project does appear to work with those versions. Opening up the old project into a MARS template scene also works. It appears to be the actual scene I’m trying to work on causing the problem. Anytime a Mars Session is added that’s when it freaks out. Nothing strange in my scene though. Adding the MarsSession moves the camera under that node and everything seems fine. As soon as I switch to SimView that’s when it freaks out, everything disappears in SimView, and everything gets put under those DELETE ME nodes in the hierarchy. Everything after that is hosed and need to restart the project.

Here’s what Build Check says:

Caution! The package dependency version is unsupported: ‘com.unity.xr.arfoundation : 2.1.8’; the detected version is ‘com.unity.xr.arfoundation : 3.1.3’

Caution! The package dependency version is unsupported: ‘com.unity.xr.arkit : 2.1.9’; the detected version is ‘com.unity.xr.arkit : 3.1.3’

Caution! The package dependency version is unsupported: ‘com.unity.xr.arkit-face-tracking : 1.0.7’; the detected version is ‘com.unity.xr.arkit-face-tracking : 3.1.3’

— The following checks were run and reported passed —
The Editor version is a match and is supported: ‘2019.3.15f1’

Required define symbols were all detected. The checked defines were:
Found : ‘UNITY_CCU’

This report was generated using the Elective Extensions config with FriendlyName: ‘iOS’

Not sure what that means re versions. I have 3.1.3 installed for each of those.

Excellent, You should only have one MARSSession game object per scene.

If you try to do the same steps that makes your app pop errors on the new scene, do you manage to get the console errors?. If so. could you write us a step by step guide on how to get said errors so I can try here?

So I have my scene which I have been working in which was an ARFoundation scene by the way. So I duplicate that so as not to screw it up into a new scene and unparent the AR Camera and remove the ARSession and ARSession Origin nodes as well as any ARFoundation components on the AR Camera just to be safe. So now its just a regular scene with a Canvas, EventSystem, and scene specific nodes.

Then I go to GameObject menu and add the MARS Session object. It grabs the camera and parents it under itself. All still good. Then I switch to the Simulation View (or Device View) and you can see the environment geo briefly but then it quickly disappears and the console fills up with hundreds of the above errors messages I first posted.

I am using the XRInteraction Toolikit also so there are some of those nodes of the camera but I would obviously assume this shouldn’t be a problem?

That’s it. Then the scene is hosed and you can’t add template scenes or do anything MARS related. Have to quit and reopen.

Oh yes, and there is only ever one MARS Session object. Creating that seems to be the problem.

Hi there! Thanks for trying MARS, and sorry that you’re having difficulty. I tried this kind of setup in a project with AR Foundation 3.1.3 and XR Interaction but wasn’t able to reproduce your issue. It sounds like we’ll need access to your project in order to reproduce the issue. Are your comfortable sharing it via the bug reporter?

If so, please open the project, go to Help > Report a Bug… and fill out the form. Make sure that you do not delete your project folder from the files field at the bottom. If it is a large project it may take a long time to upload. If this is the case, and you are able to do so, please try to replicate the issue in a smaller project and upload that.

Thanks for your patience. Once we are able to reproduce the issue we should be able to get you sorted!

Oh boy. Yeah I’m not sure I can send the project for obvious security reasons and also because it is enormous with all the assets. Is there ANY other workaround you can think of to get me up and running? New scene, setup MARS, and back in my other assets? Something like that or otherwise? Really need to be up and running. Under deadline and could use the functionality could I get it running. Thanks!

That’s understandable. Could you attach the scene file, or create a .unitypackage with the scene and any dependencies that may be necessary/helpful to reproduce the issue? With that and your project manifest (Packages/manifest.json) I may have better luck reproducing your issue. If you want to share it privately, send me a direct message.

Just DM’d you some files. Thank you!

For any internet explorers who come across this thread, scrant was able to deduce that scripts from an asset store package that uses [ExecuteInEditMode] to ensure that their object is a root in the scene. This causes exceptions during the process where we copy the scene objects into the simulation scene. We are working on a more permanent fix, but thankfully in this case it’s possible to just hack the asset store script and disable this behavior.

I will update this thread when we have released a fix.

2 Likes

Quick update: This was fixed in MARS 1.1 but I never got around to updating the thread. Objects that unparent themselves using ExecuteInEditMode no longer cause errors, but they will not show up in simulation, and may leak into preview scenes. In general, this behavior should still be avoided.

1 Like