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