Topic: Null OnlineMapsControlBase.instance

I have two different prefabs in my project and each of them has it's onlinemaps gameobject with OnlineMaps.cs and OnlineMapsTileSetControl.cs added as components.

So when i instantiate one of the prefabs, a new onlinemaps gameobject is also instantiated.

But when i destroy instantiated prefab from scene and instantiate other one i am facing OnlineMapsTileSetControl.instance is null problem. I am destroying old prefab and instantiating new prefab in same method which leads to destruction of old prefab happens after the instantiation of new one because unity has delays when destroying gameobjects.

I was looking at the code and i saw that whenever OnlineMapsControlBase is destroyed it sets _instance paremeter to null and that leads to existing OnlineMapsControlBase in scene with null instance value.

I think it should behave similar to OnlineMaps.cs

In OnlineMaps.cs there is a check before setting _instance value to null. It sets _instance to null if _instance equals the object onDisable called.

Re: Null OnlineMapsControlBase.instance


Thanks for the bug report.
You have two ways - don't use delay (by default, Destroy works immediately), or don't use singletone.
Here's a short video about it: … 8.mp4?dl=0

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.