public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { var lookup = fieldInfo.GetValue(SerializeableCollectionsPropertyHelper.GetParent(property)) as IEnumerable; // ILookup if (lookup == null) { return; } var count = lookup.GetType().GetProperty("Count", reflectionFlags).GetValue(lookup, null); foldout = EditorGUI.Foldout(position, foldout, label, true); EditorGUI.LabelField(position, label, new GUIContent() { text = "Count:" + count }); if (foldout) { // only dump:) foreach (IEnumerable item in lookup) // IGrouping { var key = item.GetType().GetProperty("Key", reflectionFlags).GetValue(item, null); foreach (var subItem in item) { position = new Rect(position.x, position.y + 17f, position.width, position.height); EditorGUI.LabelField(position, key.ToString(), (subItem == null) ? "null" : subItem.ToString()); } } } }
public override float GetPropertyHeight(SerializedProperty property, GUIContent label) { var height = base.GetPropertyHeight(property, label); var dictionary = fieldInfo.GetValue(SerializeableCollectionsPropertyHelper.GetParent(property)) as IDictionary; if (dictionary == null) { return(height); } return((foldout) ? (dictionary.Count + 1) * 17f : 17f); }
public override float GetPropertyHeight(SerializedProperty property, GUIContent label) { var height = base.GetPropertyHeight(property, label); var lookup = fieldInfo.GetValue(SerializeableCollectionsPropertyHelper.GetParent(property)) as IEnumerable; // ILookup if (lookup == null) { return(height); } var count = (int)lookup.GetType().GetProperty("Count", reflectionFlags).GetValue(lookup, null); return((foldout) ? (count + 1) * 17f : 17f); }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { var dictionary = fieldInfo.GetValue(SerializeableCollectionsPropertyHelper.GetParent(property)) as IDictionary; if (dictionary == null) { return; } foldout = EditorGUI.Foldout(position, foldout, label, true); EditorGUI.LabelField(position, label, new GUIContent() { text = "Count:" + dictionary.Count }); if (foldout) { // only dump:) foreach (DictionaryEntry item in dictionary) { position = new Rect(position.x, position.y + 17f, position.width, position.height); EditorGUI.LabelField(position, item.Key.ToString(), (item.Value == null) ? "null" : item.Value.ToString()); } } }