public override object Show() { base.ShowTitle(); for (int i = 0; i < this.fieldGUIGroups.Count; i++) { FieldGUIGroup fieldGUIGroup = this.fieldGUIGroups[i]; Action action = () => { for (int j = 0; j < fieldGUIGroup.fieldGUIs.Count; j++) { if (fieldGUIGroup.fieldGUIs[j].Unsupported && this.HideUnsupportedGUI) { continue; } fieldGUIGroup.fieldGUIs[j].Show(); } }; if (fieldGUIGroup.foldoutPanel.Title == null) { action(); } else { fieldGUIGroup.foldoutPanel.Show(action); } } return(this.Value); }
private void GenerateGUIs(object data) { FieldInfo[] fieldInfos = data.GetType().GetFields(BindingFlags.Public | BindingFlags.Instance); if (fieldInfos.Length == 0) { return; } FieldInfo fieldInfo; FieldGUIInfo fieldGUIInfo; for (var i = 0; i < fieldInfos.Length; i++) { fieldInfo = fieldInfos[i]; fieldGUIInfo = GenerateAttribute(fieldInfo); if (fieldGUIInfo.Hide) { continue; } FieldGUIBase gui = GenerateGUI(data, fieldInfo, fieldGUIInfo); this.fieldGUIs.Add(gui); FieldGUIGroup lastGroup = this.fieldGUIGroups[this.fieldGUIGroups.Count - 1]; if (lastGroup.foldoutPanel.Title == fieldGUIInfo.Group) { lastGroup.fieldGUIs.Add(gui); } else { lastGroup = new FieldGUIGroup(); lastGroup.foldoutPanel.Title = fieldGUIInfo.Group; lastGroup.fieldGUIs.Add(gui); this.fieldGUIGroups.Add(lastGroup); } } }
private void GenerateGUIs(object data) { // NOTE: // Must be reset first. if (this.fieldGUIGroups.Count > 1) { this.fieldGUIGroups.RemoveRange(1, this.fieldGUIGroups.Count); } this.fieldGUIGroups[0].GUIs.Clear(); FieldInfo[] fieldInfos = data.GetType().GetFields(BindingFlags.Public | BindingFlags.Instance); if (fieldInfos.Length == 0) { return; } for (var i = 0; i < fieldInfos.Length; i++) { FieldInfo fieldInfo = fieldInfos[i]; FieldGUIInfo guiInfo = GetFieldGUIInfo(fieldInfo); string headerInfo = GetFieldHeaderInfo(fieldInfo); if (guiInfo.Hide) { continue; } if (headerInfo != null) { FieldGUIGroup fieldGUIGroup = new FieldGUIGroup(); fieldGUIGroup.Panel.Title = headerInfo; this.fieldGUIGroups.Add(fieldGUIGroup); } this.fieldGUIGroups[this.fieldGUIGroups.Count - 1].GUIs .Add(GenerateGUI(data, fieldInfo, guiInfo)); } }