I upgraded a project running on MARS 1.1 to 1.2. Now every time i load a new scene with a MARS session i get this error constantly inside update of SimulatedDiscoveryPlanesProvider:
NullReferenceException: Object reference not set to an instance of an object
Unity.MARS.Providers.Synthetic.SimulatedDiscoveryPlanesProvider.OnMarsUpdate () (at Library/PackageCache/com.unity.mars@1.2.0/Runtime/Scripts/Providers/SimulatedProviders/SimulatedDiscoveryPlanesProvider.cs:287)
Unity.MARS.Simulation.MarsTime.InvokeMarsUpdate () (at Library/PackageCache/com.unity.mars@1.2.0/Interfaces/System/MarsTime.cs:69)
Unity.MARS.Simulation.MarsTimeModule.InvokeMarsUpdate () (at Library/PackageCache/com.unity.mars@1.2.0/Runtime/Scripts/Modules/MarsTimeModule.cs:121)
Unity.MARS.Simulation.MarsTimeModule.Unity.XRTools.ModuleLoader.IModuleBehaviorCallbacks.OnBehaviorUpdate () (at Library/PackageCache/com.unity.mars@1.2.0/Runtime/Scripts/Modules/MarsTimeModule.cs:91)
Unity.XRTools.ModuleLoader.ModuleLoaderCore.OnBehaviorUpdate ()
When i open to that line of code i see a TODO above it:
//
TODO subscribe to IProvidesSessionControl
if (m_Paused || m_SessionProvider && !m_ProvidesSessionControl.SessionRunning())
return;
Is something just unfinished here? Its definitely something around loading/unloading. Also, should the code have parenthesis around the && pair? like:
//
TODO subscribe to IProvidesSessionControl
if (m_Paused || (m_SessionProvider && !m_ProvidesSessionControl.SessionRunning()))
return;
Please help! It’s completely broken my project. Is there a work around? I’d prefer not to have to drop back to a backup and rebuild the last big chunk of work.
Hi there! I’m sorry to hear that you’re having this issue. Let’s see if we can resolve it!
I’m not able to reproduce the issue locally, so I’ll need to know a bit more about your project. The best way to do this is for you to submit a bug report, along with the project folder, and we can take a look at it. You can do this by going to Help > Report a bug… If you are not comfortable doing this, we can have you do some digging.
It will help to know some other info about your set-up. I see that this has happened after upgrading from MARS 1.1 to 1.2. What version of Unity are you using? Are you on Mac or PC? Can you explain what exactly you mean by “load a new scene?” Is this error happening in Edit Mode when you open/close scenes? Is it happening when you enter play mode on this scene? Is it happening when you start Temporal Simulation (the play button in simulation view)?
Looking at the code you posted, I don’t think those extra parenthesis would help. && takes precedence over ||, so the machine will evaluate that expression first, and should avoid calling m_ProvidesSessionControl.SessionRunning() if m_SessionProvider is null. I can’t see how this error would occur unless we somehow skipped OnEnable for this object, or somehow failed to unsubscribe its OnMarsUpdate method in OnDisable. Are there any other errors higher up in the list that are maybe getting drowned out by this one?
See if you can find anything wrong with the SimulatedDiscovery(Clone) object under the Providers section of the Content Hierarchy in MARS Panel. Does it exist when you see the errors printing? Are there any object fields on its scripts that show “Missing” or “None”? Is it enabled? Similarly, take a look at the SimulatedDiscoveryIsland asset in the Unity MARS package, and the SimulatedDiscovery prefab in its list of default providers. Is it set? Does the prefab have any missing references? It’s possible that there was a problem with importing the latest version of MARS that happened when you upgraded that we aren’t seeing on our end.