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();
        }
        // Creates an editor node.
        private BonsaiNode CreateEditorNode(Type behaviourType)
        {
            var prop = BonsaiEditor.GetNodeTypeProperties(behaviourType);
            var tex  = BonsaiPreferences.Texture(prop.texName);
            var node = AddEditorNode(prop.hasOutput, tex);

            return(node);
        }
 private void RefreshEditor()
 {
     // Reload preferences.
     BonsaiPreferences.Instance = BonsaiPreferences.LoadDefaultPreferences();
     BuildCanvas();
 }
Exemplo n.º 5
0
        private static Texture NodeIcon(Type behaviourType)
        {
            var prop = BonsaiEditor.GetNodeTypeProperties(behaviourType);

            return(BonsaiPreferences.Texture(prop.texName));
        }