public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { var state = ReadOnlyAttributeDrawer.IsEnabled(this, property); var oldState = GUI.enabled; GUI.enabled = state && oldState; if (property.propertyType == SerializedPropertyType.Vector2) { Vector2 range = property.vector2Value; float min = range.x; float max = range.y; MinMaxSliderAttribute attr = attribute as MinMaxSliderAttribute; EditorGUI.BeginChangeCheck(); #if UNITY_5_5_OR_NEWER EditorGUI.MinMaxSlider(position, label, ref min, ref max, attr.min, attr.max); #else EditorGUI.MinMaxSlider(label, position, ref min, ref max, attr.min, attr.max); #endif if (EditorGUI.EndChangeCheck()) { range.x = min; range.y = max; property.vector2Value = range; } } else { EditorGUI.LabelField(position, label, "Use only with Vector2"); } GUI.enabled = oldState; }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { var state = ReadOnlyAttributeDrawer.IsEnabled(this, property); var oldState = GUI.enabled; GUI.enabled = state && oldState; EditorGUI.PropertyField(position, property, label, true); GUI.enabled = oldState; }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { var state = ReadOnlyAttributeDrawer.IsEnabled(this, property); EditorGUI.BeginDisabledGroup(!state); var attribute = this.GetAttribute <AudioPopupAttribute>(); if (attribute != null) { var serializedObject = property.serializedObject; if (serializedObject.isEditingMultipleObjects == false) { ClipType clipType = attribute.clipType; if (string.IsNullOrEmpty(attribute.fieldName) == false) { var prop = PropertyExtensions.GetRelativeProperty(property, property.propertyPath, attribute.fieldName); clipType = (ClipType)((KeyValuePair <int, string>)PropertyExtensions.GetRawValue(prop, attribute)).Key; } Data data = null; var flowData = PropertyExtensions.GetRelativeProperty(property, property.propertyPath, "flowData"); if (flowData != null) { var _data = PropertyExtensions.GetRawValue(flowData, attribute) as UnityEngine.UI.Windows.Plugins.Flow.FlowData; if (_data != null) { data = _data.audio; } } if (data != null) { property.intValue = AudioPopupEditor.Draw(position, property.intValue, (result) => { property.intValue = result; property.serializedObject.ApplyModifiedPropertiesWithoutUndo(); }, clipType, data, label); property.serializedObject.ApplyModifiedPropertiesWithoutUndo(); } else { EditorGUI.PropertyField(position, property, label); } } } else { EditorGUI.PropertyField(position, property, label); } EditorGUI.EndDisabledGroup(); }