/***************************** ********** MAX ********** ****************************/ /// <summary> /// Restrain a property value to a maximum one. /// </summary> /// <param name="_position">Rect to draw field.</param> /// <param name="_property">Editing property.</param> /// <param name="_maxValue">Property max value.</param> public static void MaxField(Rect _position, SerializedProperty _property, float _maxValue) => MaxField(_position, _property, EditorGUIUtilityEnhanced.GetPropertyLabel(_property), _maxValue);
/**************************** ******* READONLY ******* ***************************/ /// <summary> /// Draw a readonly property field. /// </summary> /// <param name="_position">Rect to draw field in</param> /// <param name="_property">Property to display</param> public static void ReadOnlyProperty(Rect _position, SerializedProperty _property) => ReadOnlyProperty(_position, _property, EditorGUIUtilityEnhanced.GetPropertyLabel(_property), false);
/********************************* ******* ASSET PREVIEW ******* ********************************/ /// <summary> /// Draw an property field with an asset preview below it. /// </summary> /// <param name="_position">Rect to draw field in.</param> /// <param name="_property">Property to display and draw asset preview.</param> /// <param name="_foldout">The shown asset preview foldout state.</param> /// <returns>Returns new asset preview foldout state.</returns> public static bool AssetPreviewField(Rect _position, SerializedProperty _property, bool _foldout) => AssetPreviewField(_position, _property, EditorGUIUtilityEnhanced.GetPropertyLabel(_property), _foldout);
/***************************** ******** MIN MAX ******** ****************************/ /// <summary> /// Draw a min max slider field for a vector2. /// </summary> /// <param name="_position">Rect to draw field.</param> /// <param name="_property">Editing property.</param> /// <param name="_minLimit">Min allowed limit value.</param> /// <param name="_maxLimit">Max allowed limit value.</param> public static void MinMaxField(Rect _position, SerializedProperty _property, float _minLimit, float _maxLimit) => MinMaxField(_position, _property, EditorGUIUtilityEnhanced.GetPropertyLabel(_property), _minLimit, _maxLimit);
/// <summary> /// Draw a progress bar. /// </summary> /// <param name="_position">Rect to draw progress bar.</param> /// <param name="_property">Property used as value in bar progression.</param> /// <param name="_maxValue">Bar maximum value.</param> /// <param name="_color">Bar color.</param> public static void ProgressBar(Rect _position, SerializedProperty _property, float _maxValue, Color _color) => ProgressBar(_position, EditorGUIUtilityEnhanced.GetPropertyLabel(_property), _property, _maxValue, _color);
/********** EDITABLE **********/ /// <summary> /// Draw an editable progress bar. /// </summary> /// <param name="_position">Rect to draw progress bar.</param> /// <param name="_property">Property used as value in bar progression.</param> /// <param name="_maxValueVariableName">Name of the variable used as maximum value (must be in the same script as the property).</param> /// <param name="_color">Bar color.</param> public static void EditableProgressBar(Rect _position, SerializedProperty _property, string _maxValueVariableName, Color _color) => EditableProgressBar(_position, EditorGUIUtilityEnhanced.GetPropertyLabel(_property), _property, _maxValueVariableName, _color);
/********************************** ******* PROPERTY FIELD ******* *********************************/ /// <summary> /// Draw a serialized property field associated with another property ; /// when setting field value, associated property will be set automatically. /// Usefull for clamping value or calling event on inspector edit. /// </summary> /// <param name="_position">Rect to draw field in.</param> /// <param name="_property">Serialized property to edit.</param> /// <param name="_propertyName">Name of the associated property (must be in the same script as the property field).</param> public static void PropertyField(Rect _position, SerializedProperty _property, string _propertyName) => PropertyField(_position, _property, EditorGUIUtilityEnhanced.GetPropertyLabel(_property), _propertyName);
/**************************** ******* REQUIRED ******* ***************************/ /// <summary> /// Draw a required property field. /// </summary> /// <param name="_property">Property to draw and check validity.</param> public static void RequiredProperty(SerializedProperty _property) => RequiredProperty(_property, EditorGUIUtilityEnhanced.GetPropertyLabel(_property));
/********************************* ******* ASSET PREVIEW ******* ********************************/ /// <summary> /// Draw an property field with an asset preview below it. /// </summary> /// <param name="_property">Property to display and draw asset preview.</param> /// <param name="_foldout">The shown asset preview foldout state.</param> /// <param name="_previewAspect">Aspect of the displayed asset preview.</param> /// <returns>Returns new asset preview foldout state.</returns> public static bool AssetPreviewField(SerializedProperty _property, bool _foldout, float _previewAspect) => AssetPreviewField(_property, EditorGUIUtilityEnhanced.GetPropertyLabel(_property), _foldout, _previewAspect);