Fixed the existing instance being deleted in Awake#22
Conversation
Replaced `else` with `else if (instance != this)` as a condition for the instance to be deleted in Awake. This fixes a really weird bug where if singleton was used in the editor and then again in play mode, it would delete the original instance and create a new one. Closes UnityCommunity#21
|
I would highly appreciate somebody looking into this a bit deeper before merging. |
|
I am guessing it is due to the marshaling that Unity does for its objects, and Unity has a custom implementation for for That |
|
This could in turn be related to how |
I am positive it's the PR I made.
I initially tried utilizing the execution order to fix the issue I was experiencing, that didn't help tho. I tried to debug this before I came up with the solution, but I am sadly not skilled enough to figure it out. |
|
Interesting, thank you for the elaboration.
Sure, I'm interested to see how this occurs and whether this is an issue related to specific Unity versions or not. |

Replaced
elsewithelse if (instance != this)as a condition for the instance to be deleted in Awake.This fixes a really weird bug where if singleton was used in the editor and then again in play mode, it would delete the original instance and create a new one.
Closes #21