Unity Odin-ProgressBar adds a value bar

The Unity plug-in Odin provides the property [ProgressBar] to display the progress bar, but the value bar is not displayed by default, and some scripts can be customized to add the value bar;

Used by Odin BaseProgressBarAttributeDrawer<T>to handle various types of progress bars

public class ProgressBarAttributeIntWithValueDrawer : BaseProgressBarAttributeDrawer<int>
    {
        protected override int DrawProgressBar(Rect rect, GUIContent label, double min, double max, ProgressBarConfig config, string valueLabel)
        {
            rect.width -= 60;
            int result = this.Attribute.Segmented
                ? (int) SirenixEditorFields.SegmentedProgressBarField(rect, label, this.ValueEntry.SmartValue, (long) min, (long) max,
                    config, valueLabel)
                : (int) SirenixEditorFields.ProgressBarField(rect, label, this.ValueEntry.SmartValue, min, max, config,
                    valueLabel);
            Rect valueRect = rect;
            Vector3 valueRectPos = rect.position;
            valueRectPos.x += rect.width + 10;
            valueRect.position = valueRectPos;
            valueRect.width = 50;
            result = SirenixEditorFields.IntField(valueRect, "", result);
            if (result > max) result = (int) max;
            if (result < min) result = (int) min;
            return result;
        }

        protected override double ConvertToDouble(int value)
        {
            return value;
        }
    }

Effect after adding:
insert image description here

Guess you like

Origin blog.csdn.net/weixin_44054505/article/details/114672817