void InitializeView() { if (data.block == null) { return; } if (data.block is Events.HLAction || data.block is Events.HLCondition) { InitializeHLBlock(data.block); return; } var fields = EditorReflectionUtility.GetFields(data.block.GetType()); if (fields != null && fields.Length > 0) { for (int idx = 0; idx < fields.Length; idx++) { FieldInfo field = fields[idx]; if (uNodeGUIUtility.IsHide(field, data.block)) { continue; } Type type = field.FieldType; if (type == typeof(MemberData)) { MemberData member = field.GetValueOptimized(data.block) as MemberData; object[] fieldAttribute = field.GetCustomAttributes(true); if (!ReflectionUtils.TryCorrectingAttribute(data.block, ref fieldAttribute)) { continue; } var filter = ReflectionUtils.GetAttribute <FilterAttribute>(fieldAttribute); if (member == null) { if (filter != null && !filter.SetMember && !filter.OnlyGetType && ReflectionUtils.CanCreateInstance(filter.GetActualType())) { member = new MemberData(ReflectionUtils.CreateInstance(filter.GetActualType())); } else if (filter != null && !filter.SetMember && !filter.OnlyGetType) { member = MemberData.none; } field.SetValueOptimized(data.block, member); Repaint(); } bool hasDependencies = EditorReflectionUtility.HasFieldDependencies(new string[] { field.Name }, fields); var port = AddPort(new PortData() { getPortName = () => ObjectNames.NicifyVariableName(field.Name), getPortType = () => filter?.GetActualType() ?? typeof(object), getPortValue = () => field.GetValueOptimized(data.block), filter = filter, onValueChanged = (obj) => { RegisterUndo(); member = obj as MemberData; field.SetValueOptimized(data.block, member); Repaint(); if (hasDependencies) { owner.nodeView.MarkRepaint(); } }, }); port.Add(new ControlView(port.portData.InstantiateControl(true), true)); } else if (type == typeof(MultipurposeMember)) { InitMultipurposeMember(field); } else { object fieldVal = field.GetValueOptimized(data.block); object[] fieldAttribute = field.GetCustomAttributes(true); if (!ReflectionUtils.TryCorrectingAttribute(data.block, ref fieldAttribute)) { continue; } bool hasDependencies = EditorReflectionUtility.HasFieldDependencies(new string[] { field.Name }, fields); var filter = ReflectionUtils.GetAttribute <FilterAttribute>(fieldAttribute); ControlConfig config = new ControlConfig() { owner = owner.nodeView, value = fieldVal, type = type, filter = filter, onValueChanged = (obj) => { RegisterUndo(); field.SetValueOptimized(data.block, obj); Repaint(); if (hasDependencies) { owner.nodeView.MarkRepaint(); } }, }; var valueControl = UIElementUtility.CreateControl(type, config, true); AddControl(field.Name, new ControlView(valueControl, true)); if (fieldVal is IList <MemberData> ) { IList <MemberData> members = fieldVal as IList <MemberData>; if (members != null) { for (int i = 0; i < members.Count; i++) { int index = i; var member = members[i]; if (member == null) { if (filter != null && !filter.SetMember && !filter.OnlyGetType && ReflectionUtils.CanCreateInstance(filter.GetActualType())) { member = new MemberData(ReflectionUtils.CreateInstance(filter.GetActualType())); } else { member = MemberData.none; } members[index] = member; field.SetValueOptimized(data.block, members); Repaint(); } var port = AddPort(new PortData() { getPortName = () => "Element " + index.ToString(), getPortType = () => filter?.GetActualType() ?? typeof(object), getPortValue = () => (field.GetValueOptimized(data.block) as IList <MemberData>)[index], filter = filter, onValueChanged = (obj) => { RegisterUndo(); member = obj as MemberData; members[index] = member; field.SetValueOptimized(data.block, members); Repaint(); }, }); port.Add(new ControlView(port.portData.InstantiateControl(true), true)); } } } else if (fieldVal is IList) { IList list = fieldVal as IList; if (list != null) { for (int i = 0; i < list.Count; i++) { int index = i; var element = list[i]; ControlConfig cfg = new ControlConfig() { owner = owner.nodeView, value = fieldVal, type = type, filter = filter, onValueChanged = (obj) => { RegisterUndo(); field.SetValueOptimized(data.block, obj); Repaint(); }, }; var elementControl = UIElementUtility.CreateControl(type, cfg, true); AddControl("Element " + index, new ControlView(elementControl, true)); } } } } } } }