Ejemplo n.º 1
0
        protected override void SelectionChanged(IList <int> selectedIds)
        {
            int        id   = selectedIds.Count > 0 ? selectedIds[0] : -1;
            AITreeItem item = (AITreeItem)FindItem(id, rootItem);

            selectionChanged?.Invoke(item.asset);
        }
Ejemplo n.º 2
0
        protected override TreeViewItem BuildRoot()
        {
            AITreeItem root = new AITreeItem();

            IReadonlyListX <BehaviorSet> behaviorSets = db.GetAssetList <BehaviorSet>();

            foreach (BehaviorSet behaviorSet in behaviorSets)
            {
                AITreeItem behaviorSetItem = new AITreeItem(behaviorSet);
                root.AddChild(behaviorSetItem);

//                foreach (BehaviorDefinition behaviorDefinition in behaviorSet.behaviors) {
//
//                    AITreeItem behaviorItem = new AITreeItem(behaviorDefinition);
//                    behaviorSetItem.AddChild(behaviorItem);
//
//                    foreach (ActionDefinition action in behaviorDefinition.actions) {
//                        behaviorItem.AddChild(new AITreeItem(action));
//                    }
//
//                }
            }

            if (root.children == null)
            {
                root.children = new List <TreeViewItem>();
            }
            SetupDepthsFromParentsAndChildren(root);
            return(root);
        }
Ejemplo n.º 3
0
        protected override void ContextClickedItem(int id)
        {
            GenericMenu menu = new GenericMenu();
            AITreeItem  item = (AITreeItem)FindItem(id, rootItem);

            menu.AddItem(new GUIContent("Create Behavior Set"), false, () => {
                SetDataRebuildAndSelect(db.CreateAsset <BehaviorSet>().id);
            });
//            menu.AddItem(new GUIContent("Create Behavior Definition"), false, () => {
//                BehaviorDefinition behaviorDefinition = db.CreateAsset<BehaviorDefinition>();
//                item.GetBehaviorSet().AddBehaviorDefinition(behaviorDefinition);
//                SetDataRebuildAndSelect(behaviorDefinition.id);
//            });
//            menu.AddItem(new GUIContent("Create Action Definition"), false, () => {
//                BehaviorDefinition behaviorDefinition = item.GetBehaviorDefinition();
//                ActionDefinition action = db.CreateAsset<ActionDefinition>();
//                behaviorDefinition.AddActionDefinition(action);
//                SetDataRebuildAndSelect(action.id);
//            });

            menu.AddSeparator(string.Empty);
            menu.AddItem(new GUIContent($"Delete {item.displayName}"), false, () => {
                db.DestroyAsset(item.asset);
                SetDataRebuildAndSelect();
            });
            Event.current.Use();
            menu.ShowAsContext();
        }
Ejemplo n.º 4
0
        protected override DragAndDropVisualMode HandleDragAndDrop(DragAndDropArgs args)
        {
            if (args.dragAndDropPosition == DragAndDropPosition.OutsideItems)
            {
                return(DragAndDropVisualMode.Rejected);
            }

            if (!args.performDrop)
            {
                return(DragAndDropVisualMode.Move);
            }
            AITreeItem droppedItem = (AITreeItem)FindItem((int)DragAndDrop.GetGenericData("AITree_Data"), rootItem);

            if (args.parentItem == rootItem && !droppedItem.IsBehaviorSet)
            {
                return(DragAndDropVisualMode.Rejected);
            }

            AITreeItem droppedOn = (AITreeItem)args.parentItem;

            if (!droppedItem.CanDropOn(droppedOn))
            {
                return(DragAndDropVisualMode.Rejected);
            }
            else if (droppedItem.IsBehaviorSet)
            {
                OnBehaviorSetDrop(droppedItem.GetBehaviorSet(), args.insertAtIndex);
            }

            return(DragAndDropVisualMode.Move);
        }
Ejemplo n.º 5
0
 public bool CanDropOn(AITreeItem droppedOn)
 {
     switch (itemType)
     {
     case ItemType.BehaviorSet:
         return(droppedOn.IsRoot);
     }
     return(false);
 }