Unity插件Odin提供了显示进度条的属性[ProgressBar],但是默认是不显示数值栏,可以自定义修改某些脚本添加数值栏;
Odin使用的BaseProgressBarAttributeDrawer<T>
来处理多种类型的进度条
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;
}
}
添加后效果: