Пример #1
0
 public void Add(BehaviourExecutor behaviourExecutor)
 {
     if (executorsMap.Contains(behaviourExecutor))
     {
         return;
     }
     Executors.Add(behaviourExecutor);
     executorsMap.Add(behaviourExecutor);
 }
Пример #2
0
 public void Init(BehaviourExecutor executor)
 {
     if (!IsInstance)
     {
         Debug.LogError("尝试初始化未实例化的行为树: " + executor.gameObject.name);
         return;
     }
     Executor = executor;
     nodes.ForEach(InitNode);
     SortPriority();
     evaluatedComposites.Clear();
 }
Пример #3
0
        public static void CreateWindow(BehaviourExecutor executor)
        {
            if (!executor)
            {
                return;
            }
            BehaviourTreeEditor wnd = GetWindow <BehaviourTreeEditor>();

            wnd.minSize                = BehaviourTreeSettings.GetOrCreate().minWindowSize;
            wnd.titleContent           = new GUIContent("行为树编辑器");
            Selection.activeGameObject = executor.gameObject;
            EditorGUIUtility.PingObject(executor);
            wnd.ChangeTreeBySelection(executor);
        }
Пример #4
0
 private void ChangeTreeBySelection(BehaviourExecutor exe)
 {
     EditorApplication.delayCall += () =>
     {
         if (exe)
         {
             tree     = exe.Behaviour;
             latestGo = exe.gameObject;
         }
         else
         {
             latestGo = null;
         }
         SelectTree(tree);
     };
 }
Пример #5
0
 private void ChangeTreeBySelection()
 {
     EditorApplication.delayCall += () =>
     {
         BehaviourTree tree = Selection.activeObject as BehaviourTree;
         if (!tree)
         {
             if (Selection.activeGameObject)
             {
                 BehaviourExecutor exe = Selection.activeGameObject.GetComponent <BehaviourExecutor>();
                 if (exe)
                 {
                     tree     = exe.Behaviour;
                     latestGo = exe.gameObject;
                 }
             }
         }
         else
         {
             latestGo = null;
         }
         SelectTree(tree);
     };
 }
Пример #6
0
 public void Remove(BehaviourExecutor behaviourExecutor)
 {
     Executors.Remove(behaviourExecutor);
     executorsMap.Remove(behaviourExecutor);
 }