1 (edited by hunter.marquis99 2018-03-12 18:06:57)

Topic: NullReferenceException within OnlineMapsControlBase3D

After instantiating the map at runtime as a child of a canvas. I am getting reference to OnlineMaps.instance, OnlineMapsControlBase3D.instance, and OnlineMapsLocationService.instance for subscription to the OnLocationChanged, OnCompassChanged, and OnChangeZoom events after which I get a NullReferenceException from the UpdateCameraPosition function within OnlineMapsControlBase3D.

The exact line I am brought to from the editor is: if (control.smoothZoom && control.smoothZoomStarted) targetPosition = originalPosition;

I'm not sure if this is indeed a bug or if I am just simply forgetting to assign something, any ideas?

Post's attachments

NullReferenceException.PNG 99.62 kb, file has never been downloaded. 

You don't have the permssions to download the attachments of this post.

Re: NullReferenceException within OnlineMapsControlBase3D


Please explain in detail how you create the map.
It looks as though OnlineMapsControlBase.OnEnable has not yet been invoked.

Kind Regards,
Infinity Code Team

Re: NullReferenceException within OnlineMapsControlBase3D

Thank you for the fast response.

The 3D map is first constructed using the provided map wizard.

The map is made a child of a UI canvas and is saved as a prefab to be instantiated at runtime by a state machine.

Once the state is entered, the map is instantiated and the state then gets reference to the OnlineMaps instance, OnlineMapsControlBase3D instance, and OnlineMapsLocationService instance for use within the state.

After which the events OnLocationChanged, OnCompassChanged, and OnChangeZoom are subscribed to.

After much debugging it doesnt seem to be anything to do with the state itself because it is able to reach the final point in logic before the error happens.

I've used this same method for a few other states and it has worked fine. I even tried rebuilding the map with the wizard and the same issue persisted.

Re: NullReferenceException within OnlineMapsControlBase3D

I think the possible reason it is instantiating using the state machine.
Theoretically, this could create several instances of the map.
Please make sure that you always have only one instance of the map.

Kind Regards,
Infinity Code Team

Re: NullReferenceException within OnlineMapsControlBase3D

All fixed! I stopped instantiating the map along with the UI and that did the trick.

Much cleaner this way, thanks for all your help!