Exemplo n.º 1
0
 public void Add(BehaviourExecutor behaviourExecutor)
 {
     if (executorsMap.Contains(behaviourExecutor))
     {
         return;
     }
     Executors.Add(behaviourExecutor);
     executorsMap.Add(behaviourExecutor);
 }
Exemplo n.º 2
0
 public void Init(BehaviourExecutor executor)
 {
     if (!IsInstance)
     {
         Debug.LogError("尝试初始化未实例化的行为树: " + executor.gameObject.name);
         return;
     }
     Executor = executor;
     nodes.ForEach(InitNode);
     SortPriority();
     evaluatedComposites.Clear();
 }
Exemplo n.º 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);
        }
Exemplo n.º 4
0
 private void ChangeTreeBySelection(BehaviourExecutor exe)
 {
     EditorApplication.delayCall += () =>
     {
         if (exe)
         {
             tree     = exe.Behaviour;
             latestGo = exe.gameObject;
         }
         else
         {
             latestGo = null;
         }
         SelectTree(tree);
     };
 }
Exemplo n.º 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);
     };
 }
Exemplo n.º 6
0
 public void Remove(BehaviourExecutor behaviourExecutor)
 {
     Executors.Remove(behaviourExecutor);
     executorsMap.Remove(behaviourExecutor);
 }