public static object DrawVariable(Type fieldType, string fieldName, object fieldValue, string metaSuffix, bool allowExtensions, Type contextType) { GUIStyle expandButtonStyle = new GUIStyle(GUI.skin.button); RectOffset padding = expandButtonStyle.padding; padding.left = 0; padding.right = 1; expandButtonStyle.padding = padding; if (fieldValue == null) { fieldValue = TypeUtility.GetDefaultValue(fieldType); } fieldName = SidekickUtility.ParseDisplayString(fieldName); if (!string.IsNullOrEmpty(metaSuffix)) { fieldName += " " + metaSuffix; } object newValue = fieldValue; bool isArray = fieldType.IsArray; bool isGenericList = TypeUtility.IsGenericList(fieldType); if (isArray || isGenericList) { Type elementType = TypeUtility.GetElementType(fieldType); string elementTypeName = TypeUtility.NameForType(elementType); if (isGenericList) { GUILayout.Label("List<" + elementTypeName + "> " + fieldName); } else { GUILayout.Label(elementTypeName + "[] " + fieldName); } IList list = null; int previousSize = 0; if (fieldValue != null) { list = (IList)fieldValue; previousSize = list.Count; } int newSize = Mathf.Max(0, EditorGUILayout.IntField("Size", previousSize)); if (newSize != previousSize) { if (list == null) { list = (IList)Activator.CreateInstance(fieldType); } CollectionUtility.Resize(ref list, elementType, newSize); } if (list != null) { for (int i = 0; i < list.Count; i++) { list[i] = DrawIndividualVariable("Element " + i, elementType, list[i]); } } } else { // Not a collection EditorGUILayout.BeginHorizontal(); newValue = DrawIndividualVariable(fieldName, fieldType, fieldValue); if (allowExtensions) { GUI.enabled = true; // GUI.SetNextControlName( if (GUILayout.Button("->", expandButtonStyle, GUILayout.Width(20))) { OldInspectorSidekick.Current.SetSelection(fieldValue, true); } bool expanded = GUILayout.Button("...", expandButtonStyle, GUILayout.Width(20)); if (Event.current.type == EventType.Repaint) { string methodIdentifier = contextType.FullName + "." + fieldType.FullName; guiRects[methodIdentifier] = GUILayoutUtility.GetLastRect(); } // if (GUIUtility.hot { // GUILayoutUtility // gridRect = GUILayoutUtility.GetLastRect(); // gridRect.width = 100; } if (expanded) { string methodIdentifier = contextType.FullName + "." + fieldType.FullName; Rect gridRect = guiRects[methodIdentifier]; GenericMenu menu = new GenericMenu(); menu.AddItem(new GUIContent("Placeholder"), false, null); // if(fieldType == typeof(Texture)) { menu.AddItem(new GUIContent("Export PNG"), false, ExportTexture, fieldValue); } menu.DropDown(gridRect); } } EditorGUILayout.EndHorizontal(); } return(newValue); }