// Make your own IMGUI based GUI for the property public override void OnGUI(Rect _position, SerializedProperty _property, GUIContent _label) { ProgressBarAttribute _attribute = (ProgressBarAttribute)attribute; // Set label if needed if (!string.IsNullOrEmpty(_attribute.Label)) { _label.text = _attribute.Label; } // Draw editable or readonly progress bar if (_attribute.IsEditable) { if (string.IsNullOrEmpty(_attribute.MaxValueVariableName)) { EditorGUIEnhanced.EditableProgressBar(_position, _label, _property, _attribute.MaxValue, _attribute.Color.GetColor()); } else { EditorGUIEnhanced.EditableProgressBar(_position, _label, _property, _attribute.MaxValueVariableName, _attribute.Color.GetColor()); } } else { if (string.IsNullOrEmpty(_attribute.MaxValueVariableName)) { EditorGUIEnhanced.ProgressBar(_position, _label, _property, _attribute.MaxValue, _attribute.Color.GetColor()); } else { EditorGUIEnhanced.ProgressBar(_position, _label, _property, _attribute.MaxValueVariableName, _attribute.Color.GetColor()); } } }
/******************************** ******* PROGRESS BAR ******* *******************************/ /********** EDITABLE **********/ /// <summary> /// Draw an editable progress bar. /// </summary> /// <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> /// <param name="_height">Progress bar height (in pixels).</param> public static void EditableProgressBar(SerializedProperty _property, string _maxValueVariableName, Color _color, float _height) => EditorGUIEnhanced.EditableProgressBar(EditorGUILayout.GetControlRect(false, _height), _property, _maxValueVariableName, _color);
/// <summary> /// Draw an editable progress bar. /// </summary> /// <param name="_label">Label displayed in the middle of the bar.</param> /// <param name="_value">Bar progression value.</param> /// <param name="_maxValue">Bar maximum value.</param> /// <param name="_color">Bar color.</param> /// <param name="_height">Progress bar height (in pixels).</param> /// <returns>Returns new progress bar value.</returns> public static float EditableProgressBar(GUIContent _label, float _value, float _maxValue, Color _color, float _height) => EditorGUIEnhanced.EditableProgressBar(EditorGUILayout.GetControlRect(false, _height), _label, _value, _maxValue, _color);
/// <summary> /// Draw an editable progress bar. /// </summary> /// <param name="_label">Label displayed in the middle of the 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> /// <param name="_height">Progress bar height (in pixels).</param> public static void EditableProgressBar(GUIContent _label, SerializedProperty _property, float _maxValue, Color _color, float _height) => EditorGUIEnhanced.EditableProgressBar(EditorGUILayout.GetControlRect(false, _height), _label, _property, _maxValue, _color);