예제 #1
0
        public void DeserializeData()
        {
            BehaviorTreeBlueprintData mainData = editorWindow.CurrentData;

            if (mainData == null)
            {
                throw new Exception("No current data to deserialize!");
            }

            stopwatch.Restart();

            //Clear everything
            BehaviorTreeNodeAttribute.RescanAttributes();
            graphView.DeleteAllElements();
            RecalculateNodeInfo();

            //Setup data
            allData = mainData.allNodes;

            //Start
            for (int i = 0; i < mainData.rootNodes.Length; i++)
            {
                DeserializeNode(allData[mainData.rootNodes[i]]);                 //Deserialize branch
            }

            stopwatch.Stop();
            DebugHelper.Log($"Deserialized in {stopwatch.Elapsed.TotalMilliseconds} ms.");
        }
예제 #2
0
        public NodeInfo(BehaviorTreeNodeAttribute attribute)
        {
            serializedName = attribute.serializedName;
            graphNodeType  = GetTypeFromName(attribute.nodeTypeName);

            string name = BehaviorTreeNodeAttribute.SerializedNameToType[attribute.serializedName].Name;

            displayedName = name.Contains('`') ? name.Substring(0, name.IndexOf("`", StringComparison.Ordinal)) : name;
        }
예제 #3
0
        public List <SearchTreeEntry> CreateSearchTree(SearchWindowContext context)
        {
            if (searchTree == null)
            {
                searchTree = new List <SearchTreeEntry>
                {
                    new SearchTreeGroupEntry(new GUIContent("Create Node"))                                              //First item in tree is the title
                };

                BehaviorTreeNodeAttribute.RescanAttributes();
                searchTree.AddRange
                (
                    from pair in BehaviorTreeNodeAttribute.SerializedNameToAttribute
                    let entry = new NodeEntry(pair.Value)
                                select new SearchTreeEntry(new GUIContent(entry.displayedName))
                {
                    level = 1, userData = entry
                }
                );
            }

            return(searchTree);
        }
예제 #4
0
 public NodeEntry(BehaviorTreeNodeAttribute attribute) : base(attribute) => this.attribute = attribute;