public override float GetPropertyHeight(InspectableProperty property, GUIContent label) { // Try to get the sortable list this property belongs to ReorderableListData listData = null; if (listIndex.Count > 0) { listData = listIndex.Find(data => property.PropertyPath.StartsWith(data.Parent)); } return(listData != null?listData.GetPropertyHeight(property) : EasyGUI.GetPropertyHeight(property, label, property.IsExpanded)); }
private float ElementHeightCallback(SerializedProperty property, int index) { var height = 3f; var iterProp = property.GetArrayElementAtIndex(index); var elementName = iterProp.displayName; if (ElementNameCallback != null) { elementName = ElementNameCallback(index); } height += EasyGUI.GetPropertyHeight(iterProp, ElementAttributes, new GUIContent(elementName)); return(height); }
protected float GetPropertyHeight(SerializedProperty property) { var height = 0f; var listData = GetReorderableListData(property); UnityEditor.Editor scriptableEditor; var isScriptableEditor = editableDict.TryGetValue(property.propertyPath, out scriptableEditor); if (listData != null) { height += listData.GetPropertyHeight(property); if (height == 0f) { height += EditorGUI.GetPropertyHeight(property, false); if (property.isExpanded) { height += IterateGetPropertyHeight(property.Copy()); } } } else if (isScriptableEditor) { if (scriptableEditor == null) { height += EditorGUI.GetPropertyHeight(property, false); } else { height += EasyGUI.GetPropertyHeight(property, null, null, true); } } else { var isStartProp = property.propertyPath.StartsWith(M_ScriptStr); if (isStartProp && IgnoreHeader) { } else { height += EditorGUI.GetPropertyHeight(property, property.isExpanded); } } return(height); }
public static float GetObjectReferenceHeight(Object o, ReorderableListDrawer drawer = null) { var height = EditorGUIUtility.singleLineHeight + 3f; if (o != null) { var objectData = o.GetSerializedObjectData(); if (drawer != null) { drawer.IgnoreHeader = true; if (objectData.Foldout) { height += drawer.GetPropertiesAllHeights(); } } else { var iterProp = objectData.Object.GetIterator(); if (iterProp.NextVisible(true)) { int depth = iterProp.depth; do { if (depth != iterProp.depth) { break; } if (iterProp.name.Equals(M_ScriptStr)) { continue; } if (objectData.Foldout) { height += EasyGUI.GetPropertyHeight(iterProp, null, new GUIContent(iterProp.displayName), iterProp.isExpanded); } } while (iterProp.NextVisible(false)); } } } return(height); }
public float GetPropertyHeight(InspectableProperty property) { var height = EasyGUI.GetPropertyHeight(property, new GUIContent(property.DisplayName), false); if (property.IsExpanded) { for (int i = 0; i < property.ArraySize; i++) { var iterProp = property.GetArrayElementAtIndex(i); var displayName = new GUIContent(iterProp.DisplayName); if (ElementNameCallback != null) { iterProp.DisplayName = ElementNameCallback(i); displayName = iterProp.DisplayName == null ? GUIContent.none : new GUIContent(iterProp.DisplayName); } height += EasyGUI.GetInspectableObjectHeight(iterProp, displayName, IsDrawObjectReference); } height += 3 * EditorGUIUtility.singleLineHeight; } return(height); }
public bool DoProperty(Rect position, InspectableProperty property) { if (!extendListIndex.ContainsKey(property.PropertyPath)) { return(false); } headerPosition = new Rect(position); headerPosition.height = EasyGUI.GetPropertyHeight(property, GUIContent.none, false); // Draw the background if (DrawBackgroundCallback != null) { Rect backgroundPosition = new Rect(headerPosition); if (property.IsExpanded) { backgroundPosition.yMax += 19; } EditorGUI.DrawRect(backgroundPosition, DrawBackgroundCallback(false, false)); } // Draw header if (HeaderCallback != null) { HeaderCallback(headerPosition); } else { string headerName = string.Format(Header, property.DisplayName, property.ArraySize); EasyGUI.PropertyField(headerPosition, property, new GUIContent(headerName), false); } // Draw the reorderable list for the property if (property.IsExpanded) { EditorGUI.BeginDisabledGroup(!Editable); if (!property.Editable) { EditorGUI.indentLevel++; } EditorGUI.BeginChangeCheck(); var sizePosition = new Rect(position); sizePosition.yMin = headerPosition.yMax; sizePosition.yMax = headerPosition.yMax + EditorGUIUtility.singleLineHeight; var newArraySize = Mathf.Clamp(EditorGUI.IntField(sizePosition, Size, property.ArraySize), 0, int.MaxValue); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(property.InspectableObject.SerializedObject.targetObject, SetArraySize); property.ArraySize = newArraySize; EditorUtility.SetDirty(property.InspectableObject.SerializedObject.targetObject); } var listPosition = new Rect(position); listPosition.xMin += 15; listPosition.yMin = sizePosition.yMax; extendListIndex[property.PropertyPath].DoList(listPosition); if (!property.Editable) { EditorGUI.indentLevel--; } EditorGUI.EndDisabledGroup(); } return(true); }
private static bool TryDrawObjectReference(Rect position, Object o, ReorderableListDrawer drawer = null) { var result = false; if (o != null) { var objectData = o.GetSerializedObjectData(); var headerPosition = new Rect(position); headerPosition.yMin = headerPosition.yMax - EditorGUIUtility.singleLineHeight; if (drawer != null) { drawer.IgnoreHeader = true; if (objectData.Foldout) { drawer.serializedObject.Update(); var listPosition = new Rect(headerPosition); listPosition.xMin += 15; listPosition.y += EditorGUIUtility.singleLineHeight; drawer.DrawPropertiesAll(listPosition); drawer.serializedObject.ApplyModifiedProperties(); } result = true; } else { var iterProp = objectData.Object.GetIterator(); position.yMin = headerPosition.yMax; position.height = 0f; EditorGUI.BeginChangeCheck(); if (iterProp.NextVisible(true)) { EditorGUI.indentLevel++; int depth = iterProp.depth; do { if (depth != iterProp.depth) { break; } if (iterProp.name.Equals(M_ScriptStr)) { continue; } if (objectData.Foldout) { var displayName = new GUIContent(iterProp.displayName); position.yMin += position.height; position.height = EasyGUI.GetPropertyHeight(iterProp, null, displayName, iterProp.isExpanded); EasyGUI.PropertyField(position, iterProp, displayName, iterProp.isExpanded, null); } result = true; } while (iterProp.NextVisible(false)); EditorGUI.indentLevel--; } if (EditorGUI.EndChangeCheck()) { objectData.Object.ApplyModifiedProperties(); EditorSceneManager.MarkAllScenesDirty(); } } if (result) { var indentLevel = EditorGUI.indentLevel; headerPosition.xMin += EasyGUI.Indent; headerPosition.width = 5; EditorGUI.indentLevel = 0; objectData.Foldout = EditorGUI.Foldout(headerPosition, objectData.Foldout, GUIContent.none, false); EditorGUI.indentLevel = indentLevel; } } return(result); }