/// <summary> /// Draws the property. /// </summary> protected override void DrawPropertyLayout(GUIContent label) { ulong min = this.getterMinValue != null?this.getterMinValue.GetValue() : (ulong)this.Attribute.Min; ulong max = this.getterMaxValue != null?this.getterMaxValue.GetValue() : (ulong)this.Attribute.Max; if (this.getterMinValue != null && this.getterMinValue.ErrorMessage != null) { SirenixEditorGUI.ErrorMessageBox(this.getterMinValue.ErrorMessage); } if (this.getterMaxValue != null && this.getterMaxValue.ErrorMessage != null) { SirenixEditorGUI.ErrorMessageBox(this.getterMaxValue.ErrorMessage); } EditorGUI.BeginChangeCheck(); int value = SirenixEditorFields.RangeIntField(label, (int)this.ValueEntry.SmartValue, (int)Mathf.Min(min, max), (int)Mathf.Max(min, max)); if (EditorGUI.EndChangeCheck()) { if (value < (int)ulong.MinValue) { value = (int)ulong.MinValue; } else { this.ValueEntry.SmartValue = (ulong)value; } this.ValueEntry.SmartValue = (ulong)value; } }
/// <summary> /// Draws a slider for the passed <see cref="SerializedProperty"/> values. /// </summary> /// <param name="valueProp"></param> /// <param name="minProp"></param> /// <param name="maxProp"></param> public static void DrawClampRangeLayout( SerializedProperty valueProp, SerializedProperty minProp, SerializedProperty maxProp) { var valueType = GetType(valueProp); if (SUPPORTED_INT_TYPES.Contains(valueType)) { #if ODIN_INSPECTOR valueProp.intValue = SirenixEditorFields.RangeIntField( new GUIContent(valueProp.displayName), valueProp.intValue, minProp.intValue, maxProp.intValue); #else EditorGUILayout.IntSlider(valueProp, minProp.intValue, maxProp.intValue); #endif } else if (SUPPORTED_FLOAT_TYPES.Contains(valueType)) { #if ODIN_INSPECTOR valueProp.floatValue = SirenixEditorFields.RangeFloatField( new GUIContent(valueProp.displayName), valueProp.floatValue, minProp.floatValue, maxProp.floatValue); #else EditorGUILayout.Slider(valueProp, minProp.floatValue, maxProp.floatValue); #endif } }