コード例 #1
0
            public bool this[IAINode node]
            {
                get
                {
                    if (node.IsNullOrDestroyed())
                    {
                        return(true);
                    }

                    bool result;
                    if (_table.TryGetValue(AITreeDebugWindow.GetNodeHash(node), out result))
                    {
                        return(result);
                    }
                    return(true);
                }
                set
                {
                    if (node.IsNullOrDestroyed())
                    {
                        return;
                    }

                    _table[AITreeDebugWindow.GetNodeHash(node)] = value;
                }
            }
コード例 #2
0
 private static void OpenWindow()
 {
     if (_window == null)
     {
         _window = EditorWindow.GetWindow <AITreeDebugWindow>();
         _window.Show();
         _window.position = new Rect(20, 80, 500, 300);
     }
     else
     {
         _window.Focus();
     }
 }
コード例 #3
0
        private void DrawNode(IAINode node)
        {
            var  rect        = EditorGUILayout.GetControlRect();
            bool hasChildren = (node is IAIActionGroup || node is IAIStateMachine);

            //first click region
            if (MouseUtil.GuiClicked(Event.current, MouseUtil.BTN_LEFT, rect))
            {
                _currentSelectionId = AITreeDebugWindow.GetNodeHash(node);
                if (node is Component)
                {
                    Selection.activeGameObject = (node as Component).gameObject;
                    EditorGUIUtility.PingObject(node as Component);
                }
                this.Repaint();
            }
            else if (MouseUtil.GuiClicked(Event.current, MouseUtil.BTN_RIGHT, rect))
            {
                this.DrawPopup(node);
            }

            //draw selection rect
            if (_currentSelectionId == AITreeDebugWindow.GetNodeHash(node))
            {
                EditorGUI.DrawRect(rect, _selectedColor);
            }

            //draw label
            if (hasChildren)
            {
                _currentTable[node] = EditorGUI.Foldout(rect, _currentTable[node], node.DisplayName);
            }
            else
            {
                EditorGUI.LabelField(rect, node.DisplayName);
            }

            //highlight if running
            if (node is IAIAction)
            {
                var act = node as IAIAction;
                switch (act.ActionState)
                {
                case ActionResult.Waiting:
                    EditorGUI.DrawRect(rect, _waitingColor);
                    break;

                case ActionResult.Success:
                    EditorGUI.DrawRect(rect, _successColor);
                    break;

                case ActionResult.Failed:
                    EditorGUI.DrawRect(rect, _failedColor);
                    break;
                }
            }
            else if (node is IAIState)
            {
                var state = node as IAIState;
                if (state.IsActive)
                {
                    EditorGUI.DrawRect(rect, _activeStateColor);
                }
            }


            if (hasChildren && _currentTable[node])
            {
                EditorGUI.indentLevel++;
                if (node is IAIActionGroup)
                {
                    foreach (var child in (node as IAIActionGroup))
                    {
                        this.DrawNode(child);
                    }
                }
                else if (node is IAIStateMachine)
                {
                    foreach (var child in (node as IAIStateMachine))
                    {
                        this.DrawNode(child);
                    }
                }
                EditorGUI.indentLevel--;
            }
        }