public VariableView(VariableData variable, IVariableSystem owner, ExplorerVariableData data = null) { if (data == null) { data = new ExplorerVariableData(); } data.guid = variable.Name; this.data = data; this.variable = variable; this.owner = owner; title = $"{variable.Name} : {variable.type.DisplayName(false, false)}"; titleIcon.image = uNodeEditorUtility.GetTypeIcon(typeof(TypeIcons.FieldIcon)); expandedElement.visible = false; titleContainer.RegisterCallback <MouseDownEvent>(evt => { if (evt.clickCount >= 2 && evt.button == 0 && owner is uNodeRoot) { uNodeEditor.ChangeTarget(owner as uNodeRoot, true); uNodeEditor.window.ChangeEditorSelection(GraphUtility.GetTempGraphVariable(variable.Name, owner as uNodeRoot) ?? variable); } }); if (ExplorerManager.explorerData.showSummary) { if (!string.IsNullOrWhiteSpace(variable.summary)) { var summary = new SummaryView(variable.summary); headerContainer.Add(summary); } } if (ExplorerManager.explorerData.showTypeIcon) { typeIcon = new Image() { name = "type-icon", image = uNodeEditorUtility.GetTypeIcon(variable.type), }; titleContainer.Add(typeIcon); typeIcon.PlaceInFront(titleIcon); } }
public void SetData(ITreeData value) { data = value as ExplorerVariableData; }
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)); } } }; }