Example #1
0
        public override void OnInspectorGUI()
        {
            DrawDefaultInspector();

            EditorGUILayout.BeginVertical();

            string message;

            if (_bIsLinking)
            {
                message = "Finish Linking";
            }

            else
            {
                message = "Link Guards";
            }

            if (GUILayout.Button(message))
            {
                // Toggle
                _bIsLinking = !_bIsLinking;

                if (_bIsLinking)
                {
                    parentWindow.inputHandler.StartReferenceLinking(typeof(Guard), onNodeSelectedForLinking);
                    parentWindow.Repaint();
                }

                else
                {
                    parentWindow.inputHandler.EndReferenceLinking();
                    parentWindow.Repaint();
                }
            }

            if (parentWindow)
            {
                _bIsLinking = parentWindow.inputHandler.IsRefLinking;
            }

            EditorGUILayout.EndVertical();

            if (GUI.changed)
            {
                // Synchronize the key values.
                foreach (Guard linkedGuard in _guard.linkedGuards)
                {
                    linkedGuard.maxActiveGuards         = _guard.maxActiveGuards;
                    linkedGuard.waitUntilChildAvailable = _guard.waitUntilChildAvailable;
                    linkedGuard.returnSuccessOnSkip     = _guard.returnSuccessOnSkip;
                }
            }
        }
        public override void OnInspectorGUI()
        {
            DrawDefaultInspector();

            EditorGUILayout.BeginVertical();

            string message;

            if (_bIsLinking)
            {
                message = "Finish Linking";
            }

            else
            {
                message = "Link Interruptables";
            }

            if (GUILayout.Button(message))
            {
                // Toggle
                _bIsLinking = !_bIsLinking;

                if (_bIsLinking)
                {
                    parentWindow.inputHandler.StartReferenceLinking(typeof(Interruptable), onNodeSelectedForLinking);
                    parentWindow.Repaint();
                }

                else
                {
                    parentWindow.inputHandler.EndReferenceLinking();
                    parentWindow.Repaint();
                }
            }

            if (parentWindow)
            {
                _bIsLinking = parentWindow.inputHandler.IsRefLinking;
            }

            EditorGUILayout.EndVertical();
        }
        private static bool OpenCanvasAsset(int instanceID, int line)
        {
            var treeSelected = EditorUtility.InstanceIDToObject(instanceID) as BehaviourTree;

            if (treeSelected != null)
            {
                BonsaiWindow windowToUse = null;

                // Try to find an editor window without a canvas...
                var bonsaiWindows = Resources.FindObjectsOfTypeAll <BonsaiWindow>();
                foreach (var w in bonsaiWindows)
                {
                    // The canvas is already opened
                    if (w.Tree == treeSelected)
                    {
                        return(false);
                    }

                    // Found a window with no active canvas.
                    if (w.Tree == null)
                    {
                        windowToUse = w;
                        break;
                    }
                }

                // No windows available...just make a new one.
                if (!windowToUse)
                {
                    windowToUse = CreateInstance <BonsaiWindow>();
                    windowToUse.Show();
                }

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

                windowToUse.SetTree(treeSelected);
                windowToUse.Repaint();
                return(true);
            }

            return(false);
        }
Example #4
0
        private static bool OpenCanvasAsset(int instanceID, int line)
        {
            var treeSelected = EditorUtility.InstanceIDToObject(instanceID) as Core.BehaviourTree;

            if (treeSelected != null)
            {
                BonsaiWindow windowToUse = null;

                // Try to find an editor window without a canvas...
                var bonsaiWindows = Resources.FindObjectsOfTypeAll <BonsaiWindow>();
                foreach (var w in bonsaiWindows)
                {
                    // The canvas is already opened
                    if (w.tree == treeSelected)
                    {
                        return(false);
                    }

                    // Found a window with no active canvas.
                    if (w.tree == null)
                    {
                        windowToUse = w;
                        break;
                    }
                }

                // No windows available...just make a new one.
                if (!windowToUse)
                {
                    windowToUse = EditorWindow.CreateInstance <BonsaiWindow>();
                    windowToUse.titleContent = new GUIContent("Bonsai");
                    windowToUse.Show();
                }

                windowToUse.SetTree(treeSelected);
                windowToUse.saveManager.InitState();
                windowToUse.Repaint();

                return(true);
            }

            return(false);
        }