-
Notifications
You must be signed in to change notification settings - Fork 1
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
Unsafe to instantiate GameManager
before first scene load
#3
Comments
Hello, thank you for the bug report! You're right on most The core issue seems to lie in I'll try to think of something to workaround this. |
Found and implemented better solution using profiles, see https://github.com/chark/game-management/releases/tag/v0.0.2:
Let me know if I created more bugs 😅 |
game-management/Packages/com.chark.game-management/Runtime/GameManager.cs
Line 47 in c28434b
Most of the available values of the
RuntimeInitializeOnLoadType
enum are not safe to use to instantiate theGameManager
instance in built players, including the default value of.BeforeSceneLoad
shown in the example. SinceGameManager
derives fromMonoBehaviour
and must be attached to aGameObject
, there must be a scene loaded for the newGameObject
to be added to. Those values do work in the editor since there is already a scene loaded in the editor, but aGameObject
instantiated before the first scene load in a built player will be leaked/lost after that first scene load, even ifDontDestroyOnLoad
is used.The result of this is that all calls to
GameManager.*
throw aNullReferenceException
in builds, but do work in the editor.The text was updated successfully, but these errors were encountered: