Beispiel #1
0
        public void Run(BehaviorTree tree)
        {
            if (BTEditor.Instance.CurTreeGO == null)
            {
                return;
            }
            if (BTEditor.Instance.CurTreeGO.GetInstanceID() != tree.GameObjectId)
            {
                return;
            }

            BTDebugComponent btDebugComponent = BTEditor.Instance.GetComponent <BTDebugComponent>();

            if (btDebugComponent.OwnerId != 0 && tree.Id != 0 && btDebugComponent.OwnerId != tree.Id)
            {
                return;
            }

            btDebugComponent.Add(tree.Id, tree.PathList);
            if (!btDebugComponent.IsFrameSelected)
            {
                BTEditor.Instance.ClearDebugState();
                BTEditor.Instance.SetDebugState(tree.PathList);
            }
        }
Beispiel #2
0
        public void DrawDebugView()
        {
            BTDebugComponent    btDebugComponent = BTEditor.Instance.GetComponent <BTDebugComponent>();
            List <List <long> > treePathList     = btDebugComponent.Get(btDebugComponent.OwnerId);

            GUILayout.BeginHorizontal();
            GUILayout.Label("行为树Id:");
            btDebugComponent.OwnerId = EditorGUILayout.LongField(btDebugComponent.OwnerId);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("清空执行记录"))
            {
                treePathList.Clear();
                BTEditor.Instance.ClearDebugState();
            }

            if (GUILayout.Button("清除帧选择"))
            {
                btDebugComponent.IsFrameSelected = false;
            }
            GUILayout.EndHorizontal();

            const float offset = 55f;

            GUILayout.BeginArea(new Rect(0f, 60f, this.mWidth, Screen.height - offset));
            this.mTreeScrollPos = GUI.BeginScrollView(
                new Rect(0f, 0f, this.mWidth, Screen.height - offset), this.mTreeScrollPos,
                new Rect(0f, 0f, this.mWidth - 20f, treePathList.Count * 22), false, false);


            for (int i = 0; i < treePathList.Count; i++)
            {
                if (GUILayout.Button($"frame{i}"))
                {
                    btDebugComponent.IsFrameSelected = true;
                    BTEditor.Instance.ClearDebugState();
                    BTEditor.Instance.SetDebugState(treePathList[i]);
                }
            }
            GUI.EndScrollView();
            GUILayout.EndArea();
        }