public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { if (SerializedPropertyUtility.IsArrayElement(property)) { if (SerializedPropertyUtility.IndexOfArrayElement(property) == 0) { //EditorGUI.PropertyField(new Rect(position.x, position.y, position.width, EditorGUIUtility.singleLineHeight), property, true); //position.y += EditorGUIUtility.singleLineHeight; firstProperty = property; SerializedProperty parentProp = SerializedPropertyUtility.GetArrayParentProperty(property); if (list == null || list.serializedProperty.propertyPath != parentProp.propertyPath) { list = new ReorderableList(parentProp.serializedObject, parentProp, true, true, true, true); list.drawElementCallback += DrawElement; list.elementHeightCallback += ElementHeightCallback; list.drawHeaderCallback += DrawHeader; //list.drawFooterCallback += DrawFooter; } if (list != null) { list.elementHeight = maxHeight; //list.DoLayoutList(); list.DoList(new Rect(position.x, position.y, position.width, maxHeight)); } } } }
// Entry Point public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { if (showDebug) { Rect sliderRect = new Rect(0, position.y, position.width, normalHeight); labelWidthPercent = EditorGUI.Slider(sliderRect, labelWidthPercent, 0, 1); sliderRect.y += debugTool; position.yMin += debugTool; } float yMax = position.yMax; currHeight = 0; EditorGUI.indentLevel = 0; isCalcHeight = false; SetupGUIStyle(); // Inspector Label Width labelWidth = position.width * labelWidthPercent; EditorGUIUtility.labelWidth = labelWidth; currProperty = property.propertyPath; SerializedProperty origProp = null; // Special case of array element (4.3) if (SerializedPropertyUtility.IsArrayElement(property)) { isArrayElement = true; arrayElementIndex = SerializedPropertyUtility.IndexOfArrayElement(property); origProp = SerializedPropertyUtility.GetArrayParentProperty(property); } else { origProp = property.Copy(); } AutoPropertyField(position, property, origProp, label, 0, out yMax); // delay action if (action != null) { action.Action(); action = null; } GUI.skin = null; }
public override float GetPropertyHeight(SerializedProperty property, GUIContent label) { float h = 0; // base.GetPropertyHeight(property, label); if (SerializedPropertyUtility.IsArrayElement(property)) { if (SerializedPropertyUtility.IndexOfArrayElement(property) == 0) { h += EditorGUIUtility.singleLineHeight; // header h += EditorGUIUtility.singleLineHeight; // footer //SerializedProperty parentProp = SerializedPropertyUtility.GetArrayParentProperty(property); } //h += EditorGUI.GetPropertyHeight(property); h += maxHeight; } return(h); }
public override float GetPropertyHeight(SerializedProperty property, GUIContent label) { SerializedProperty origProp = property; bool backupFlag = isArrayElement; if (SerializedPropertyUtility.IsArrayElement(property)) { isArrayElement = true; arrayElementIndex = SerializedPropertyUtility.IndexOfArrayElement(property); origProp = SerializedPropertyUtility.GetArrayParentProperty(property); } else { origProp = property.Copy(); } float height = GetPropertyHeight(property, origProp, label) + (1) + ((showDebug)? debugTool: 0); isArrayElement = backupFlag; return(height); }