private static void OnPlayModeChanged(UnityEditor.PlayModeStateChange state) { switch (state) { case UnityEditor.PlayModeStateChange.EnteredPlayMode: DisposeAgent(); _agent = InitializeAgent(UnityUIAgentEditorRuntime.Create(GetRoot())); CurrentInterfaceType = _agent.GetInterfaceType(); break; case UnityEditor.PlayModeStateChange.EnteredEditMode: DisposeAgent(); _agent = InitializeAgent(UnityUIAgentEditor.Create()); CurrentInterfaceType = _agent.GetInterfaceType(); break; } }
private static void Initialize() { _agent = InitializeAgent(UnityUIAgentEditor.Create()); UnityEditor.EditorApplication.playModeStateChanged += OnPlayModeChanged; }