Exemple #1
0
 public EnumView(EnumData enumData, uNodeData owner)
 {
     this.enumData    = enumData;
     this.owner       = owner;
     title            = enumData.name;
     titleIcon.image  = uNodeEditorUtility.GetTypeIcon(typeof(TypeIcons.EnumIcon));
     onFirstExpanded += () => {
         foreach (var e in enumData.enumeratorList)
         {
             var item = new SimpleTreeView(uNodeEditorUtility.GetTypeIcon(typeof(TypeIcons.EnumItemIcon)), null)
             {
                 title = e.name,
             };
             AddChild(item);
         }
     };
 }
Exemple #2
0
        public void Refresh()
        {
            foreach (var item in items)
            {
                item.RemoveFromHierarchy();
            }
            var prefabs = uNodeEditorUtility.FindPrefabsOfType <uNodeComponentSystem>();

            prefabs.Sort((x, y) => string.CompareOrdinal(x.gameObject.name, y.gameObject.name));
            macros.Clear();
            graphs.Clear();
            foreach (var p in prefabs)
            {
                var comp = p.GetComponent <uNodeComponentSystem>();
                if (comp is uNodeMacro)
                {
                    macros.Add(comp as uNodeMacro);
                }
                else
                {
                    var comps = p.GetComponents <uNodeComponentSystem>();
                    if (comps.Length == 1 && comps[0] is IIndependentGraph)
                    {
                        graphs.Add(comps[0]);
                    }
                    else
                    {
                        graphs.Add(p);
                    }
                }
            }

            if (explorerData.showGraph)
            {
                graphTree = new SimpleTreeView()
                {
                    title    = "Graphs",
                    manager  = this,
                    expanded = explorerData.expandGraphs,
                };
                graphTree.onExpandClicked += () => {
                    if (!graphTree.isInSearch)
                    {
                        explorerData.expandGraphs = graphTree.expanded;
                        Save();
                    }
                };
                foreach (var g in graphs)
                {
                    if (g is GameObject)
                    {
                        string uid       = uNodeUtility.GetObjectID(g).ToString();
                        var    childData = explorerData.objects.FirstOrDefault(d => d.guid == uid);
                        if (childData == null)
                        {
                            childData = new ExplorerObjectData();
                            explorerData.objects.Add(childData);
                        }
                        graphTree.AddChild(new ObjectTreeView(g as GameObject, childData));
                    }
                    else if (g is uNodeRoot graph)
                    {
                        string uid       = uNodeUtility.GetObjectID(graph).ToString();
                        var    childData = explorerData.graphs.FirstOrDefault(d => d.guid == uid);
                        if (childData == null)
                        {
                            childData = new ExplorerGraphData();
                            explorerData.graphs.Add(childData);
                        }
                        graphTree.AddChild(new GraphTreeView(graph, childData));
                    }
                }
                graphTree.Initialize();
                Add(graphTree);
                items.Add(graphTree);
            }
            if (explorerData.showMacro)
            {
                macroTree = new SimpleTreeView()
                {
                    title    = "Macros",
                    manager  = this,
                    expanded = explorerData.expandMacros,
                };
                macroTree.onExpandClicked += () => {
                    if (!macroTree.isInSearch)
                    {
                        explorerData.expandMacros = macroTree.expanded;
                        Save();
                    }
                };
                foreach (var m in macros)
                {
                    string uid       = uNodeUtility.GetObjectID(m).ToString();
                    var    childData = explorerData.graphs.FirstOrDefault(d => d.guid == uid);
                    if (childData == null)
                    {
                        childData = new ExplorerGraphData();
                        explorerData.graphs.Add(childData);
                    }
                    macroTree.AddChild(new GraphTreeView(m, childData));
                }
                macroTree.Initialize();
                Add(macroTree);
                items.Add(macroTree);
            }
        }