void OnEnable() { BonsaiPreferences.Instance = BonsaiPreferences.LoadDefaultPreferences(); BonsaiEditor.FetchBehaviourNodes(); Editor = new BonsaiEditor(); Viewer = new BonsaiViewer(); Saver = new BonsaiSaver(); Saver.SaveMessage += (sender, message) => ShowNotification(new GUIContent(message)); Editor.Viewer = Viewer; Editor.Input.SaveRequest += (s, e) => Save(); Editor.CanvasChanged += (s, e) => Repaint(); Editor.Input.MouseDown += (s, e) => Repaint(); Editor.Input.MouseUp += (s, e) => Repaint(); Editor.EditorMode.ValueChanged += (s, mode) => { EditorMode = mode; }; EditorApplication.playModeStateChanged += PlayModeStateChanged; BuildCanvas(); // Always start in edit mode. // // The only way it can be in view mode is if the window is // already opened and the user selects a game object with a // behaviour tree component. Editor.EditorMode.Value = BonsaiEditor.Mode.Edit; }
void OnEnable() { BonsaiPreferences.Instance = BonsaiPreferences.LoadDefaultPreferences(); BonsaiEditor.FetchBehaviourNodes(); Editor = new BonsaiEditor(); Viewer = new BonsaiViewer(); Saver = new BonsaiSaver(); Saver.SaveMessage += (sender, message) => ShowNotification(new GUIContent(message)); Editor.Viewer = Viewer; Editor.Input.SaveRequest += (s, e) => Save(); Editor.CanvasChanged += (s, e) => Repaint(); Editor.Input.MouseDown += (s, e) => Repaint(); Editor.Input.MouseUp += (s, e) => Repaint(); Editor.EditorMode.ValueChanged += (s, mode) => { EditorMode = mode; }; EditorApplication.playModeStateChanged += PlayModeStateChanged; AssemblyReloadEvents.beforeAssemblyReload += BeforeAssemblyReload; Selection.selectionChanged += SelectionChanged; BuildCanvas(); Editor.EditorMode.Value = BonsaiEditor.Mode.Edit; SwitchToViewModeIfRequired(); }