-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Plugin fails to work if CountlyManager.Init is called from an Awake #1
Comments
Looks good, I think you want to move the DontDestroyOnLoad outside the check you added, otherwise the bug originally reported will still occur if the user calls LoadLevel later on. |
Wow, missed that one! Thanks for pointing it out. I think the best would be to call an initializer method both from the Instance property and from the Awake method for the case where a user calls LoadLevel during overall Awake and before CountlyManager's own Awake gets fired.
if SomeObject's Awake gets fired before CountlyManager's, In theory LoadLevel is synchronous so _instance exists for a while (due to the cal to CountlyManager.Instance) but then I guess since I don't do any DontDestroy when I call the Instance property the Awake doesn't get to run and therefore the manager object doesn't manager to survive. Anyway, I don't think many people would do such kind of thing so it looks good enough to me. |
I think your completely correct that the initializer needs to be called on the Instance property (when it creates a new instance lazily ). I'm going to close this issue though. |
Because the order of the CountlyManager awake and any other awake is undefined. The result is the already initialized CountlyManager getting destroyed by it's own Awake.
The text was updated successfully, but these errors were encountered: