Beispiel #1
0
        public ObjectTreeView(GameObject gameObject, ExplorerObjectData data = null)
        {
            if (data == null)
            {
                data = new ExplorerObjectData();
            }
            data.guid = uNodeUtility.GetObjectID(gameObject).ToString();
            expanded  = data.expanded;
            this.data = data;

            this.gameObject = gameObject;
            title           = gameObject.name;

            onExpandClicked += () => {
                if (!isInSearch)
                {
                    data.expanded = expanded;
                    Save();
                }
            };

            onFirstExpanded += () => {
                var components = gameObject.GetComponents <uNodeComponentSystem>();
                foreach (var c in components)
                {
                    if (c is uNodeRoot)
                    {
                        string uid       = uNodeUtility.GetObjectID(c).ToString();
                        var    childData = data.components.FirstOrDefault(d => d.guid == uid) as ExplorerGraphData;
                        if (childData == null)
                        {
                            childData = new ExplorerGraphData();
                            data.components.Add(childData);
                        }
                        AddChild(new GraphTreeView(c as uNodeRoot, childData));
                    }
                    else if (c is uNodeData)
                    {
                        var root = c as uNodeData;
                        if (ExplorerManager.explorerData.showEnum)
                        {
                            foreach (var e in root.enums)
                            {
                                AddChild(new EnumView(e, root));
                            }
                        }
                        if (ExplorerManager.explorerData.showInterface)
                        {
                            foreach (var i in root.interfaces)
                            {
                                AddChild(new InterfaceView(i, root));
                            }
                        }
                    }
                }
            };
        }
Beispiel #2
0
 public void SetData(ITreeData value)
 {
     data = value as ExplorerGraphData;
 }
Beispiel #3
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);
            }
        }
Beispiel #4
0
        public GraphTreeView(uNodeRoot root, ExplorerGraphData data = null)
        {
            if (data == null)
            {
                data = new ExplorerGraphData();
            }
            data.guid = uNodeUtility.GetObjectID(root).ToString();
            expanded  = data.expanded;
            this.data = data;
            this.root = root;
            title     = root.DisplayName;

            titleContainer.RegisterCallback <MouseDownEvent>(evt => {
                if (evt.clickCount >= 2 && evt.button == 0)
                {
                    uNodeEditor.ChangeTarget(root, true);
                }
            });
            onExpandClicked += () => {
                if (!isInSearch)
                {
                    data.expanded = expanded;
                    Save();
                }
            };

            if (!string.IsNullOrWhiteSpace(root.summary) && ExplorerManager.explorerData.showSummary)
            {
                var summary = new SummaryView(root.summary);
                headerContainer.Add(summary);
            }
            if (root is ICustomIcon)
            {
                titleIcon.image = uNodeEditorUtility.GetTypeIcon(root);
            }
            else if (root is IMacroGraph)
            {
                titleIcon.image = uNodeEditorUtility.GetTypeIcon(typeof(TypeIcons.GraphIcon));
            }
            else if (root is IClassSystem)
            {
                titleIcon.image = uNodeEditorUtility.GetTypeIcon((root as IClassSystem).IsStruct ? typeof(TypeIcons.StructureIcon) : typeof(TypeIcons.ClassIcon));
            }
            else
            {
                titleIcon.image = uNodeEditorUtility.GetTypeIcon(typeof(TypeIcons.RuntimeTypeIcon));
            }

            onFirstExpanded += () => {
                if (ExplorerManager.explorerData.showVariable)
                {
                    foreach (var v in root.Variables)
                    {
                        string uid       = v.Name;
                        var    childData = data.variables.FirstOrDefault(d => d.guid == uid);
                        if (childData == null)
                        {
                            childData = new ExplorerVariableData();
                            data.variables.Add(childData);
                        }
                        AddChild(new VariableView(v, root, childData));
                    }
                }
                if (ExplorerManager.explorerData.showProperty)
                {
                    foreach (var p in root.Properties)
                    {
                        string uid       = uNodeUtility.GetObjectID(p).ToString();
                        var    childData = data.properties.FirstOrDefault(d => d.guid == uid);
                        if (childData == null)
                        {
                            childData = new ExplorerPropertyData();
                            data.properties.Add(childData);
                        }
                        AddChild(new PropertyView(p, childData));
                    }
                }
                if (ExplorerManager.explorerData.showFunction)
                {
                    foreach (var f in root.Functions)
                    {
                        string uid       = uNodeUtility.GetObjectID(f).ToString();
                        var    childData = data.functions.FirstOrDefault(d => d.guid == uid);
                        if (childData == null)
                        {
                            childData = new ExplorerFunctionData();
                            data.functions.Add(childData);
                        }
                        AddChild(new FunctionView(f, childData));
                    }
                }
            };
        }