当前位置:网站首页>Unity Odin ProgressBar add value column

Unity Odin ProgressBar add value column

2022-04-23 20:34:00 One Mr rabbit one

Unity plug-in unit Odin Provides properties for displaying progress bars [ProgressBar], But the default is not to display the value column , You can customize and modify some scripts and add value Columns ;

Odin The use of BaseProgressBarAttributeDrawer<T> To handle multiple 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 picture description here

版权声明
本文为[One Mr rabbit one]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204210548406458.html