public override float GetPropertyHeight(SerializedProperty property, GUIContent label) { if (!property.isArray) { return(EditorGUIUtility.singleLineHeight); } if (property.arraySize == 0) { property.arraySize = 1; } if (property.arraySize == 1) { return((_internalDrawer != null) ? _internalDrawer.GetPropertyHeight(property.GetArrayElementAtIndex(0), EditorHelper.TempContent("Element 0")) : EditorGUIUtility.singleLineHeight); } else { var h = EditorGUIUtility.singleLineHeight; var lbl = EditorHelper.TempContent("Element 0"); for (int i = 0; i < property.arraySize; i++) { h += (_internalDrawer != null) ? _internalDrawer.GetPropertyHeight(property.GetArrayElementAtIndex(i), lbl) : EditorGUIUtility.singleLineHeight; } return(h); } }
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 float GetHeight(SerializedProperty property, GUIContent label, bool includeChildren) { if (_visibleDrawer == null) { this.Init(); } property = property.Copy(); if (label == null) { label = EditorHelper.TempContent(property.displayName); } if (_visibleDrawer is IArrayHandlingPropertyDrawer || !property.isArray) { return(_visibleDrawer.GetPropertyHeight(property, label)); } else { float h = SPEditorGUI.GetSinglePropertyHeight(property, label); if (!includeChildren || !property.isExpanded) { return(h); } h += EditorGUIUtility.singleLineHeight + 2f; for (int i = 0; i < property.arraySize; i++) { var pchild = property.GetArrayElementAtIndex(i); h += _visibleDrawer.GetPropertyHeight(pchild, EditorHelper.TempContent(pchild.displayName)) + 2f; } return(h); } }
public override float GetPropertyHeight(SerializedProperty property, GUIContent label) { Init(); if (IsBinding(property)) { return(base.GetPropertyHeight(property, label)); } else { return(baseDrawer.GetPropertyHeight(property, label)); } }
private void BeginProperty(SerializedProperty property, GUIContent label) { var valuesProp = property.FindPropertyRelative(PROP_VALUES); _label = label; _lst = CachedReorderableList.GetListDrawer(valuesProp, _lst_DrawHeader, _lst_DrawElement); _lst.displayAdd = false; _lst.displayRemove = false; _lst.draggable = false; if (valuesProp.arraySize > 0) { var el = valuesProp.GetArrayElementAtIndex(0); if (OverridePropertyDrawer != null) { _lst.elementHeight = OverridePropertyDrawer.GetPropertyHeight(el, GUIContent.none); } else { _lst.elementHeight = SPEditorGUI.GetPropertyHeight(el); } } else { _lst.elementHeight = EditorGUIUtility.singleLineHeight; } }
public override float GetPropertyHeight(SerializedProperty property, GUIContent label) { if (fieldInfo.GetCustomAttributes(typeof(PropertyAttribute), false).Count() > 1) { _multipleAttributes = true; GetPropertyDrawerType(property); } else if (!fieldInfo.FieldType.Module.ScopeName.Equals(typeof(int).Module.ScopeName)) { _specialType = true; GetTypeDrawerType(property); } _toShow = Attribute.CheckPropertyVisible(property); if (!_toShow) { return(0); } if (_genericDrawerInstance != null) { return(_genericDrawerInstance.GetPropertyHeight(property, label)); } if (_genericTypeDrawerInstance != null) { return(_genericTypeDrawerInstance.GetPropertyHeight(property, label)); } return(EditorGUI.GetPropertyHeight(property)); }
public override float GetPropertyHeight(SerializedProperty property, GUIContent label) { if (!(attribute is ConditionalFieldAttribute conditional)) { return(0); } Initialize(property); var propertyToCheck = ConditionalFieldUtility.FindRelativeProperty(property, conditional.FieldToCheck); _toShow = ConditionalFieldUtility.PropertyIsVisible(propertyToCheck, conditional.Inverse, conditional.CompareValues); if (!_toShow) { return(0); } if (_customAttributeDrawer != null) { return(_customAttributeDrawer.GetPropertyHeight(property, label)); } if (_customTypeDrawer != null) { return(_customTypeDrawer.GetPropertyHeight(property, label)); } return(EditorGUI.GetPropertyHeight(property)); }
protected virtual float GetElementHeight(SerializedProperty property) { int elementIndex = List.IndexOf(property); PropertyDrawer drawer = GetDrawer(Target.Components[elementIndex].GetType()); return(drawer.GetPropertyHeight(property, GUIContent.none) + EditorGUIUtility.singleLineHeight + POPUP_SPACING); }
public static float GetHeight(SerializedProperty property, GUIContent label, PropertyDrawer drawerOverride = null) { if (drawerOverride != null) { return(drawerOverride.GetPropertyHeight(property, label)); } return(EditorGUI.GetPropertyHeight(property, label) + 12); }
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) { 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) { if (!ShowMe(property)) { return(0f); } return(propertyDrawer == null? base.GetPropertyHeight(property, label) : propertyDrawer.GetPropertyHeight(property, label)); }
protected virtual void DrawInspector(Rect rect, out Rect inspectorRect, int elementIndex, SerializedProperty element) { PatternComponent currentComponent = Target.Components[elementIndex]; Type type = currentComponent.GetType(); PropertyDrawer drawer = GetDrawer(type); float requiredHeight = drawer.GetPropertyHeight(element, GUIContent.none); inspectorRect = new Rect(rect.x, rect.y + rect.height, rect.width, requiredHeight); drawer.OnGUI(inspectorRect, element, GUIContent.none); }
public static float GetPropertyHeight(SerializedProperty property, GUIContent label) { PropertyDrawer drawer = GetDrawer(property); if (drawer != null) { return(drawer.GetPropertyHeight(property, label)); } else { return(EditorGUI.GetPropertyHeight(property, label)); } }
private void OnGuiHandler() { EditorGUI.BeginChangeCheck(); _property.serializedObject.Update(); var content = new GUIContent(_property.displayName); var height = _drawer.GetPropertyHeight(_property, content); var rect = EditorGUILayout.GetControlRect(true, height); _drawer.OnGUI(rect, _property, content); _property.serializedObject.ApplyModifiedProperties(); EditorGUI.EndChangeCheck(); }
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); }
public override float GetPropertyHeight(SerializedProperty property, GUIContent label) { if (!ShowMe(property)) { return(0); } if (complexTypeDrawer != null) { return(complexTypeDrawer.GetPropertyHeight(property, label)); } // The height of the property should be defaulted to the default height. return(base.GetPropertyHeight(property, label)); }
public override float GetPropertyHeight(SerializedProperty property, GUIContent label) { if (!_initialized) { this.Init(true); } if (_subDrawer != null) { return(_subDrawer.GetPropertyHeight(property, label)); } else { return(base.GetPropertyHeight(property, label)); } }
protected virtual void DrawBehaviourContent() { float requiredHeight = 0; requiredHeight += EditorGUIUtility.singleLineHeight; requiredHeight += BEHAVIOUR_PADDING_TOP; requiredHeight += BEHAVIOUR_PADDING_BOTTOM; requiredHeight += POPUP_SPACING; if (Target.Behaviour != null) { Type type = Target.Behaviour.GetType(); PropertyDrawer drawer = GetDrawer(type); requiredHeight += drawer.GetPropertyHeight(Behaviour, GUIContent.none); } Rect rect = EditorGUILayout.GetControlRect(false, requiredHeight); if (Event.current.type == EventType.Repaint) { Styles.BoxBackground.Draw(rect, GUIContent.none, 0); } using (new EditorGUI.IndentLevelScope()) { rect.y += BEHAVIOUR_PADDING_TOP; rect.width -= 5; DrawBehaviourPopup(rect); rect.y += EditorGUIUtility.singleLineHeight + POPUP_SPACING; if (Target.Behaviour != null) { Type type = Target.Behaviour.GetType(); PropertyDrawer drawer = GetDrawer(type); DrawBehaviourInspector(rect, drawer); } } }
public override float GetPropertyHeight(SerializedProperty property, GUIContent label) { if (!(attribute is ConditionalFieldAttribute conditional)) { return(EditorGUI.GetPropertyHeight(property)); } CachePropertyDrawer(property); _toShow = ConditionalUtility.IsPropertyConditionMatch(property, conditional.Data); if (!_toShow) { return(0); } if (_customPropertyDrawer != null) { return(_customPropertyDrawer.GetPropertyHeight(property, label)); } return(EditorGUI.GetPropertyHeight(property)); }
public override float GetPropertyHeight(SerializedProperty property, GUIContent label) { Initialize(property); _toShow = ConditionalFieldUtility.PropertyIsVisible(_conditionalToTarget[property], _attribute.Inverse, _attribute.CompareValues); if (!_toShow) { return(0); } if (_genericDrawerInstance != null) { return(_genericDrawerInstance.GetPropertyHeight(property, label)); } if (_genericTypeDrawerInstance != null) { return(_genericTypeDrawerInstance.GetPropertyHeight(property, label)); } return(EditorGUI.GetPropertyHeight(property)); }
/// <returns>Inspector height</returns> private static float DrawInspector <T>(GenericField <T> field, SerializedObject objectReference, SerializedProperty property, Rect rect) where T : ScriptableObject { if (field.Instance == null) { return(0); } if (PropertyDrawerLoader.Drawers.ContainsKey(field.Type)) { PropertyDrawer customDrawer = PropertyDrawerLoader.Drawers[field.Type]; rect.height = customDrawer.GetPropertyHeight(property, GUIContent.none); customDrawer.OnGUI(rect, property, GUIContent.none); } else { rect.height = GeneralPropertyDrawer.Drawer.GetPropertyHeight(objectReference, property, GUIContent.none); GeneralPropertyDrawer.Drawer.OnGUI(rect, objectReference, property, GUIContent.none); } return(rect.height); }
public override float GetPropertyHeight(SerializedProperty property, GUIContent label) { var attributeType = ((PropertyFieldAttribute)attribute).attributeType; var arguments = ((PropertyFieldAttribute)attribute).arguments; if (attributeType == null) { drawerOverride = GetPropertyDrawer(fieldInfo.FieldType, fieldInfo); } else { drawerOverride = GetPropertyAttributeDrawer(attributeType, fieldInfo, arguments); } if (drawerOverride == null) { return(base.GetPropertyHeight(property, label)); } else { return(drawerOverride.GetPropertyHeight(property, label)); } }
public override float GetPropertyHeight(SerializedProperty property, GUIContent label) { PropertyDrawer polyDrawer = GetPolyPropertyDrawer(property); return(polyDrawer == null?base.GetPropertyHeight(property, label) : polyDrawer.GetPropertyHeight(property, label)); }
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); } }