public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { bool cache = property.isExpanded; property.isExpanded = true; if (!property.hasChildren) { SPEditorGUI.DefaultPropertyField(position, property, label); return; } float h = SPEditorGUI.GetDefaultPropertyHeight(property, label, true) + BOTTOM_PAD + TOP_PAD - EditorGUIUtility.singleLineHeight; var area = new Rect(position.x, position.yMax - h, position.width, h); var drawArea = new Rect(area.x, area.y + TOP_PAD, area.width - MARGIN, area.height - TOP_PAD); GUI.BeginGroup(area, label, GUI.skin.box); GUI.EndGroup(); EditorGUI.indentLevel++; SPEditorGUI.FlatChildPropertyField(drawArea, property); EditorGUI.indentLevel--; property.isExpanded = cache; }
private CachedReorderableList GetList(SerializedProperty property, GUIContent label) { var lst = CachedReorderableList.GetListDrawer(property, _maskList_DrawHeader, _maskList_DrawElement); lst.draggable = _draggable; if (property.arraySize > 0) { if (_drawElementAtBottom) { lst.elementHeight = EditorGUIUtility.singleLineHeight; } else { var pchild = property.GetArrayElementAtIndex(0); if (_internalDrawer != null) { lst.elementHeight = _internalDrawer.GetPropertyHeight(pchild, label); } else { lst.elementHeight = SPEditorGUI.GetDefaultPropertyHeight(pchild, label) + 1f; } } } else { lst.elementHeight = EditorGUIUtility.singleLineHeight; } return(lst); }
public override float GetPropertyHeight(SerializedProperty property, GUIContent label) { bool cache = property.isExpanded; property.isExpanded = true; try { if (property.hasChildren) { return(SPEditorGUI.GetDefaultPropertyHeight(property, label, true) + BOTTOM_PAD + TOP_PAD - EditorGUIUtility.singleLineHeight); } else { return(SPEditorGUI.GetDefaultPropertyHeight(property, label)); } } catch (System.Exception ex) { throw ex; } finally { property.isExpanded = cache; } }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { if (label == null) { label = EditorHelper.TempContent(property.displayName); } if (!property.isArray) { if (_drawer != null) { _drawer.OnGUI(position, property, label); } else { SPEditorGUI.DefaultPropertyField(position, property, label); } } else { if (property.isExpanded) { var rect = new Rect(position.xMin, position.yMin, position.width, EditorGUIUtility.singleLineHeight); property.isExpanded = EditorGUI.Foldout(rect, property.isExpanded, label); EditorGUI.indentLevel++; rect = new Rect(rect.xMin, rect.yMax + 2f, rect.width, EditorGUIUtility.singleLineHeight); property.arraySize = Mathf.Max(0, EditorGUI.IntField(rect, "Size", property.arraySize)); var lbl = EditorHelper.TempContent(""); for (int i = 0; i < property.arraySize; i++) { var pchild = property.GetArrayElementAtIndex(i); lbl.text = pchild.displayName; if (_drawer != null) { var h = _drawer.GetPropertyHeight(pchild, lbl); rect = new Rect(rect.xMin, rect.yMax + 2f, rect.width, h); _drawer.OnGUI(rect, pchild, lbl); } else { var h = SPEditorGUI.GetDefaultPropertyHeight(pchild, lbl); rect = new Rect(rect.xMin, rect.yMax + 2f, rect.width, h); SPEditorGUI.DefaultPropertyField(rect, pchild, lbl); } } EditorGUI.indentLevel--; } else { property.isExpanded = EditorGUI.Foldout(position, property.isExpanded, label); } } }
public override float GetPropertyHeight(SerializedProperty property, GUIContent label) { if (property.hasChildren) { return(SPEditorGUI.GetDefaultPropertyHeight(property, label, true) + BOTTOM_PAD + TOP_PAD - EditorGUIUtility.singleLineHeight); } else { return(SPEditorGUI.GetDefaultPropertyHeight(property, label)); } }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { bool canShrink = this.attribute is DisplayFlatAttribute ? (this.attribute as DisplayFlatAttribute).CanShrinkAndExpand : false; bool cache = property.isExpanded; if (!canShrink) { property.isExpanded = true; } try { if (!property.hasChildren) { SPEditorGUI.DefaultPropertyField(position, property, label); return; } if (canShrink) { cache = SPEditorGUI.PrefixFoldoutLabel(position, property.isExpanded, GUIContent.none); } if (property.isExpanded) { float h = SPEditorGUI.GetDefaultPropertyHeight(property, label, true) + BOTTOM_PAD + TOP_PAD - EditorGUIUtility.singleLineHeight; var area = new Rect(position.x, position.yMax - h, position.width, h); var drawArea = new Rect(area.x, area.y + TOP_PAD, area.width - MARGIN, area.height - TOP_PAD); GUI.BeginGroup(area, label, GUI.skin.box); GUI.EndGroup(); EditorGUI.indentLevel++; SPEditorGUI.FlatChildPropertyField(drawArea, property); EditorGUI.indentLevel--; } else { GUI.BeginGroup(position, label, GUI.skin.box); GUI.EndGroup(); } } catch (System.Exception ex) { throw ex; } finally { property.isExpanded = cache; } }
public override float GetPropertyHeight(SerializedProperty property, GUIContent label) { if (!property.isArray) { return(SPEditorGUI.GetDefaultPropertyHeight(property, label)); } if (!this.ManuallyConfigured && !(this.attribute is WeightedValueCollectionAttribute)) { return(SPEditorGUI.GetDefaultPropertyHeight(property, label)); } return(base.GetPropertyHeight(property, label)); }
public override float GetPropertyHeight(SerializedProperty property, GUIContent label) { float h; if (EditorHelper.AssertMultiObjectEditingNotSupportedHeight(property, label, out h)) { return(h); } if (property.isArray) { this.StartOnGUI(property, label); if (_disallowFoldout || property.isExpanded) { h = _lst.GetHeight(); if (_drawElementAtBottom && _lst.index >= 0 && _lst.index < property.arraySize) { var pchild = property.GetArrayElementAtIndex(_lst.index); bool cache = pchild.isExpanded; pchild.isExpanded = true; if (_internalDrawer != null) { h += _internalDrawer.GetPropertyHeight(pchild, label) + BOTTOM_PAD + TOP_PAD; } else if (pchild.hasChildren) { h += SPEditorGUI.GetDefaultPropertyHeight(pchild, label, true) + BOTTOM_PAD + TOP_PAD - EditorGUIUtility.singleLineHeight; } else { h += SPEditorGUI.GetDefaultPropertyHeight(pchild, label, true) + BOTTOM_PAD + TOP_PAD; } pchild.isExpanded = cache; } } else { h = EditorGUIUtility.singleLineHeight; } } else { h = EditorGUIUtility.singleLineHeight; } return(h); }
private CachedReorderableList GetList(SerializedProperty property, GUIContent label) { var lst = CachedReorderableList.GetListDrawer(property, _maskList_DrawHeader, _maskList_DrawElement, _addCallback); lst.draggable = _draggable; if (property.arraySize > 0) { if (_drawElementAtBottom) { lst.elementHeight = EditorGUIUtility.singleLineHeight; } else { var pchild = property.GetArrayElementAtIndex(0); if (_internalDrawer != null) { lst.elementHeight = _internalDrawer.GetPropertyHeight(pchild, label); } else if (ElementIsFlatChildField(pchild)) { //we don't draw this way if it's a built-in type from Unity pchild.isExpanded = true; if (_hideElementLabel) { lst.elementHeight = SPEditorGUI.GetDefaultPropertyHeight(pchild, label, true) + 2f - EditorGUIUtility.singleLineHeight; } else { lst.elementHeight = SPEditorGUI.GetDefaultPropertyHeight(pchild, label, true) + 2f; //height when showing label } } else { lst.elementHeight = SPEditorGUI.GetDefaultPropertyHeight(pchild, label) + 1f; } } } else { lst.elementHeight = EditorGUIUtility.singleLineHeight; } return(lst); }
public override float GetPropertyHeight(SerializedProperty property, GUIContent label) { float h; if (EditorHelper.AssertMultiObjectEditingNotSupportedHeight(property, label, out h)) { return(h); } if (property.isArray) { this.StartOnGUI(property, label); if (_disallowFoldout || property.isExpanded) { h = _lst.GetHeight(); if (_drawElementAtBottom && _lst.index >= 0 && _lst.index < property.arraySize) { var pchild = property.GetArrayElementAtIndex(_lst.index); if (_internalDrawer != null) { h += _internalDrawer.GetPropertyHeight(pchild, label) + BOTTOM_PAD + TOP_PAD; } else if (ElementIsFlatChildField(pchild)) { //we don't draw this way if it's a built-in type from Unity pchild.isExpanded = true; h += SPEditorGUI.GetDefaultPropertyHeight(pchild, label, true) + BOTTOM_PAD + TOP_PAD - EditorGUIUtility.singleLineHeight; } else { h += SPEditorGUI.GetDefaultPropertyHeight(pchild, label, false) + BOTTOM_PAD + TOP_PAD; } } } else { h = EditorGUIUtility.singleLineHeight; } } else { h = EditorGUIUtility.singleLineHeight; } return(h); }
public override float GetPropertyHeight(SerializedProperty property, GUIContent label) { if (label == null) { label = EditorHelper.TempContent(property.displayName); } if (!property.isArray) { if (_drawer != null) { return(_drawer.GetPropertyHeight(property, label)); } else { return(SPEditorGUI.GetDefaultPropertyHeight(property)); } } else { float h = SPEditorGUI.GetSinglePropertyHeight(property, label); if (!property.isExpanded) { return(h); } h += EditorGUIUtility.singleLineHeight + 2f; for (int i = 0; i < property.arraySize; i++) { var pchild = property.GetArrayElementAtIndex(i); if (_drawer != null) { h += _drawer.GetPropertyHeight(pchild, EditorHelper.TempContent(pchild.displayName)) + 2f; } else { h += SPEditorGUI.GetPropertyHeight(pchild, EditorHelper.TempContent(pchild.displayName)) + 2f; } } return(h); } }
public override float GetPropertyHeight(SerializedProperty property, GUIContent label) { bool canShrink = this.attribute is DisplayFlatAttribute ? (this.attribute as DisplayFlatAttribute).CanShrinkAndExpand : false; bool cache = property.isExpanded; if (!canShrink) { property.isExpanded = true; } try { if (property.isExpanded) { if (property.hasChildren) { return(SPEditorGUI.GetDefaultPropertyHeight(property, label, true) + BOTTOM_PAD + TOP_PAD - EditorGUIUtility.singleLineHeight); } else { return(SPEditorGUI.GetDefaultPropertyHeight(property, label)); } } else { return(EditorGUIUtility.singleLineHeight + BOTTOM_PAD); } } catch (System.Exception ex) { throw ex; } finally { property.isExpanded = cache; } }
private CachedReorderableList GetList(SerializedProperty property, GUIContent label) { var lst = CachedReorderableList.GetListDrawer(property, _maskList_DrawHeader, _maskList_DrawElement, _addCallback); lst.draggable = _draggable; if (property.arraySize > 0) { if (_drawElementAtBottom) { lst.elementHeight = EditorGUIUtility.singleLineHeight; } else { var pchild = property.GetArrayElementAtIndex(0); if (_internalDrawer != null) { lst.elementHeight = _internalDrawer.GetPropertyHeight(pchild, label); } else if (pchild.hasChildren && pchild.objectReferenceValue is MonoBehaviour) { //we don't draw this way if it's a built-in type from Unity lst.elementHeight = SPEditorGUI.GetDefaultPropertyHeight(pchild, label, true) + 2f; } else { lst.elementHeight = SPEditorGUI.GetDefaultPropertyHeight(pchild, label) + 1f; } } } else { lst.elementHeight = EditorGUIUtility.singleLineHeight; } return(lst); }
protected virtual float GetElementHeight(SerializedProperty element, GUIContent label, bool elementIsAtBottom) { if (_internalDrawer != null) { return(_internalDrawer.GetPropertyHeight(element, label)); } else if (ElementIsFlatChildField(element)) { //we don't draw this way if it's a built-in type from Unity element.isExpanded = true; if (_hideElementLabel || elementIsAtBottom) { return(SPEditorGUI.GetDefaultPropertyHeight(element, label, true) - EditorGUIUtility.singleLineHeight); } else { return(SPEditorGUI.GetDefaultPropertyHeight(element, label, true)); } } else { return(SPEditorGUI.GetDefaultPropertyHeight(element, label, false)); } }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { if (EditorHelper.AssertMultiObjectEditingNotSupported(position, property, label)) { return; } if (property.isArray) { if (_disallowFoldout) { this.StartOnGUI(property, label); //_lst.DoList(EditorGUI.IndentedRect(position)); _lst.DoList(position); this.EndOnGUI(property, label); } else { const float WIDTH_FOLDOUT = 5f; if (property.isExpanded) { this.StartOnGUI(property, label); property.isExpanded = EditorGUI.Foldout(new Rect(position.xMin, position.yMin, WIDTH_FOLDOUT, EditorGUIUtility.singleLineHeight), property.isExpanded, GUIContent.none); //_lst.DoList(EditorGUI.IndentedRect(position)); _lst.DoList(position); this.EndOnGUI(property, label); } else { if (_removeBackgroundWhenCollapsed) { property.isExpanded = EditorGUI.Foldout(position, property.isExpanded, label); } else { property.isExpanded = EditorGUI.Foldout(new Rect(position.xMin, position.yMin, WIDTH_FOLDOUT, EditorGUIUtility.singleLineHeight), property.isExpanded, GUIContent.none); //ReorderableListHelper.DrawRetractedHeader(EditorGUI.IndentedRect(position), label); ReorderableListHelper.DrawRetractedHeader(position, label); } } } if (_drawElementAtBottom && _lst.index >= 0 && _lst.index < property.arraySize) { var pchild = property.GetArrayElementAtIndex(_lst.index); var label2 = TempElementLabel(pchild, _lst.index); //(string.IsNullOrEmpty(_childPropertyAsLabel)) ? TempElementLabel(_lst.index) : GUIContent.none; pchild.isExpanded = true; float h; if (_internalDrawer != null) { h = _internalDrawer.GetPropertyHeight(pchild, label2) + BOTTOM_PAD; } else { h = SPEditorGUI.GetDefaultPropertyHeight(pchild, label2, true) + BOTTOM_PAD; } var area = new Rect(position.x, position.yMax - h, position.width, h); GUI.BeginGroup(area, label2, GUI.skin.box); GUI.EndGroup(); if (_internalDrawer != null) { _internalDrawer.OnGUI(area, pchild, label2); } else { SPEditorGUI.DefaultPropertyField(area, pchild, GUIContent.none, true); } } } else { EditorGUI.PropertyField(position, property, label, false); } }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { if (EditorHelper.AssertMultiObjectEditingNotSupported(position, property, label)) { return; } if (property.isArray) { if (this.CustomLabel != null) { label = this.CustomLabel; } else if (label != null) { label = EditorHelper.CloneContent(label); if (_showTooltipInHeader) { label.text = string.Format("{0} [{1:0}] - {2}", label.text, property.arraySize, (string.IsNullOrEmpty(label.tooltip) ? property.tooltip : label.tooltip)); } else { label.text = string.Format("{0} [{1:0}]", label.text, property.arraySize); } if (string.IsNullOrEmpty(label.tooltip)) { label.tooltip = property.tooltip; } } else { label = EditorHelper.TempContent(property.displayName, property.tooltip); } //const float WIDTH_FOLDOUT = 5f; var foldoutRect = new Rect(position.xMin, position.yMin, position.width, EditorGUIUtility.singleLineHeight); position = EditorGUI.IndentedRect(position); Rect listArea = position; if (_disallowFoldout) { listArea = new Rect(position.xMin, position.yMin, position.width, _lst.GetHeight()); this.StartOnGUI(property, label); //_lst.DoList(EditorGUI.IndentedRect(position)); _lst.DoList(listArea); this.EndOnGUI(property, label); } else { if (property.isExpanded) { listArea = new Rect(position.xMin, position.yMin, position.width, _lst.GetHeight()); this.StartOnGUI(property, label); property.isExpanded = EditorGUI.Foldout(foldoutRect, property.isExpanded, GUIContent.none); //_lst.DoList(EditorGUI.IndentedRect(position)); _lst.DoList(listArea); this.EndOnGUI(property, label); } else { if (_removeBackgroundWhenCollapsed) { property.isExpanded = EditorGUI.Foldout(foldoutRect, property.isExpanded, label); } else { property.isExpanded = EditorGUI.Foldout(foldoutRect, property.isExpanded, GUIContent.none); //ReorderableListHelper.DrawRetractedHeader(EditorGUI.IndentedRect(position), label); ReorderableListHelper.DrawRetractedHeader(position, label); } } } this.DoDragAndDrop(property, listArea); if (property.isExpanded && _drawElementAtBottom && _lst.index >= 0 && _lst.index < property.arraySize) { var pchild = property.GetArrayElementAtIndex(_lst.index); var label2 = TempElementLabel(pchild, _lst.index); //(string.IsNullOrEmpty(_childPropertyAsLabel)) ? TempElementLabel(_lst.index) : GUIContent.none; pchild.isExpanded = true; float h; if (_internalDrawer != null) { h = _internalDrawer.GetPropertyHeight(pchild, label2) + BOTTOM_PAD + TOP_PAD; } else if (pchild.hasChildren) { h = SPEditorGUI.GetDefaultPropertyHeight(pchild, label, true) + BOTTOM_PAD + TOP_PAD - EditorGUIUtility.singleLineHeight; } else { h = SPEditorGUI.GetDefaultPropertyHeight(pchild, label2, true) + BOTTOM_PAD + TOP_PAD; } var area = new Rect(position.xMin, position.yMax - h, position.width, h); var drawArea = new Rect(area.xMin, area.yMin + TOP_PAD, area.width - MARGIN, area.height - TOP_PAD); GUI.BeginGroup(area, label2, GUI.skin.box); GUI.EndGroup(); EditorGUI.indentLevel++; if (_internalDrawer != null) { _internalDrawer.OnGUI(drawArea, pchild, label2); } else if (pchild.hasChildren) { SPEditorGUI.FlatChildPropertyField(drawArea, pchild); } else { SPEditorGUI.DefaultPropertyField(drawArea, pchild, GUIContent.none, false); } EditorGUI.indentLevel--; } } else { SPEditorGUI.DefaultPropertyField(position, property, label, false); } }