Ejemplo n.º 1
0
        void OnEnable()
        {
            //BonsaiPreferences.Current = 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.OnEditorModeChanged += (s, mode) => { EditorMode = mode; };

            EditorApplication.playModeStateChanged    += PlayModeStateChanged;
            AssemblyReloadEvents.beforeAssemblyReload += BeforeAssemblyReload;
            Selection.selectionChanged += SelectionChanged;

            BuildCanvas();
            Editor.EditorMode = BonsaiEditor.Mode.Edit;
            SwitchToViewModeIfRequired();
        }
Ejemplo n.º 2
0
 private void CreateNew()
 {
     QuickSave();
     SetTree(BonsaiSaver.CreateBehaviourTree());
     Editor.Canvas.CreateRootNode();
     ShowNotification(new GUIContent("New Tree Created"));
 }
Ejemplo n.º 3
0
        static bool OpenCanvasAsset(int instanceID, int line)
        {
            var          tree = EditorUtility.InstanceIDToObject(instanceID) as BehaviorTree;
            BonsaiWindow w    = OpenTree(tree);

            if (w)
            {
                // If a tree asset was created but has no blackboard, add one upon opening.
                // This is for convenience.
                BonsaiSaver.AddBlackboardIfMissing(tree);

                w.SwitchToViewModeIfRequired();
            }

            return(w);
        }