Any idea why enteredPlayMode gets called more than once when I play my empty scene with only this script in it?
Usually I get 2-3 logs.
[InitializeOnLoad]
public class GameModeEvents : MonoBehaviourSingleton<GameModeEvents>
{
GameModeEvents()
{
EditorApplication.playModeStateChanged += playmodeStateChanged;
}
private void playmodeStateChanged(PlayModeStateChange playMode)
{
switch (playMode)
{
case PlayModeStateChange.EnteredPlayMode:
//this gets called multiple times
Debug.Log("entered playmode");
break;
}
}
}
I suspect the I am subscribing multiple times when the constructor gets called? Moving the subscription into the Awake function seems to fix the multiple call issue, but cause some order issues for me…