Example #1
0
        private void SelectBehaviorBrain()
        {
            GUIContent content = new GUIContent(BehaviorTreesEditor.active != null ? BehaviorTreesEditor.active.name : "[None Selected]");
            float      width   = EditorStyles.toolbarDropDown.CalcSize(content).x;

            width = Mathf.Clamp(width, 100f, width);
            if (GUILayout.Button(content, EditorStyles.toolbarDropDown, GUILayout.Width(width)))
            {
                GenericMenu menu = new GenericMenu();
                if (BehaviorTreesEditor.active != null)
                {
                    SelectBehaviorBrainMenu(BehaviorTreesEditor.active, ref menu);
                }

                menu.AddItem(new GUIContent("[Create New]"), false, delegate()
                {
                    BehaviorTrees bt = AssetCreator.CreateAsset <BehaviorTrees>(true);
                    if (bt != null)
                    {
                        bt.Name = bt.name;

                        Root root   = BehaviorTreesEditorUtility.AddNode <Root>(BehaviorTreesEditor.center, bt);
                        bt.rootNode = root;
                        root.Name   = "Root";

                        AssetCreator.SaveAIAsset();
                        BehaviorTreesEditor.SelectBehaviorTrees(bt);
                    }
                });
                menu.ShowAsContext();
            }
        }
Example #2
0
 private void SelectBehaviorBrainMenu(BehaviorTrees bt, ref GenericMenu menu)
 {
     if (bt != null)
     {
         GUIContent content = new GUIContent(bt.name);
         menu.AddItem(content, false, delegate()
         {
             BehaviorTreesEditor.SelectBehaviorTrees(bt);
         });
     }
 }
Example #3
0
        public static void SelectGameObject(GameObject gameObject)
        {
            if (BehaviorTreesEditor.instance == null)
            {
                return;
            }

            if (gameObject != null)
            {
                Brain brain = gameObject.GetComponent <Brain>();
                BehaviorTreesEditor.instance._brain = brain;
                if (brain != null && brain.behaviorTrees != null)
                {
                    BehaviorTreesEditor.instance._activeGameObject = gameObject;
                    BehaviorTreesEditor.SelectBehaviorTrees(brain.behaviorTrees);
                }
            }
        }