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.

uContext is Editor PowerPack (more than 40 tools) that take your workflow in Unity Editor to a next level, simplifies working with content, adds new features, corrects and improves the editor’s built-in behaviors. Click here to download uContext Basic for free.