public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { this.ConfigureSettings(); if (_disallowFoldout) { this.OnGUIStart(property, label); _lst.DoList(position); this.OnGUIEnd(); } else { if (property.isExpanded) { this.OnGUIStart(property, label); var foldoutRect = new Rect(position.xMin, position.yMin, 20f, EditorGUIUtility.singleLineHeight); property.isExpanded = EditorGUI.Foldout(foldoutRect, property.isExpanded, GUIContent.none); _lst.DoList(position); this.OnGUIEnd(); } else { property.isExpanded = EditorGUI.Foldout(position, property.isExpanded, GUIContent.none); ReorderableListHelper.DrawRetractedHeader(position, label); } } }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { if (EditorHelper.AssertMultiObjectEditingNotSupported(position, property, label)) { return; } this.Init(property, label); var cache = SPGUI.DisableIfPlaying(); _maskList.DoList(position); cache.Reset(); }
private Rect DrawList(Rect position, SerializedProperty property) { var listRect = new Rect(position.xMin, position.yMin, position.width, _targetList.GetHeight()); EditorGUI.BeginChangeCheck(); _targetList.DoList(listRect); if (EditorGUI.EndChangeCheck()) { property.serializedObject.ApplyModifiedProperties(); } if (_targetList.index >= _targetList.count) { _targetList.index = -1; } return(new Rect(position.xMin, listRect.yMax, position.width, position.height - listRect.height)); }
private Rect DrawList(Rect position, SerializedProperty property) { var listRect = new Rect(position.xMin, position.yMin, position.width, _targetList.GetHeight()); EditorGUI.BeginChangeCheck(); _targetList.DoList(listRect); if (EditorGUI.EndChangeCheck()) { property.serializedObject.ApplyModifiedProperties(); } if (_targetList.index >= _targetList.count) { _targetList.index = -1; } var ev = Event.current; if (ev != null) { switch (ev.type) { case EventType.DragUpdated: case EventType.DragPerform: { if (listRect.Contains(ev.mousePosition)) { var refs = DragAndDrop.objectReferences; DragAndDrop.visualMode = refs.Length > 0 ? DragAndDropVisualMode.Link : DragAndDropVisualMode.Rejected; if (ev.type == EventType.DragPerform && refs.Length > 0) { ev.Use(); AddObjectsToTrigger(property, refs); } } } break; } } return(new Rect(position.xMin, listRect.yMax, position.width, position.height - listRect.height)); }
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); } }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { if (EditorHelper.AssertMultiObjectEditingNotSupported(position, property, label)) { return; } this.Init(property, label, true); _currentLabel = label; if (this.fieldInfo.DeclaringType == typeof(SPAnimationController)) { _currentLabel.text = "Animation States"; } property.isExpanded = SPEditorGUI.PrefixFoldoutLabel(position, property.isExpanded, GUIContent.none); if (!property.isExpanded) { //here we emulate the ReorderableList header //ReorderableListHelper.DrawRetractedHeader(EditorGUI.IndentedRect(position), label); ReorderableListHelper.DrawRetractedHeader(position, label); } else { //var cache = SPGUI.DisableIfPlaying(); _animList.displayAdd = !Application.isPlaying; _animList.displayRemove = !Application.isPlaying; _animList.draggable = !Application.isPlaying; EditorGUI.BeginChangeCheck(); //_animList.DoList(EditorGUI.IndentedRect(position)); _animList.DoList(position); if (EditorGUI.EndChangeCheck()) { property.serializedObject.ApplyModifiedProperties(); } if (!_hideDetailRegion && _animList.index >= 0) { try { var detailRect = new Rect(position.xMin, position.yMin + _animList.GetHeight(), position.width, this.GetDetailHeight()); var stateProp = _animList.serializedProperty.GetArrayElementAtIndex(_animList.index); var nameProp = stateProp.FindPropertyRelative("_name"); GUI.BeginGroup(detailRect, nameProp.stringValue, GUI.skin.box); GUI.EndGroup(); //draw basic details var buffer = EditorGUIUtility.singleLineHeight + 2f; detailRect = new Rect(detailRect.xMin, detailRect.yMin + buffer, detailRect.width, detailRect.height - buffer); _clipDrawer.DrawDetails(detailRect, stateProp); } catch { //failed to draw details because poorly selected nonsense } } //cache.Reset(); } }