更新日 2022/7/15
【Unity】プログレスバーを表示するエディター拡張方法を紹介します!
プログレスバーを表示するエディター拡張方法をシンプルに紹介します。

目次
ProgressBar属性を作成する
プログレスバー表示用の空のプロパティー属性を作成します。
ProgressBarAttribute.cs
using System;
namespace UnityEngine
{
[AttributeUsage(AttributeTargets.Field)]
public class ProgressBarAttribute : PropertyAttribute
{
}
}
ProgressBarDrawerの作成
プログレスバーを表示するのにEditorGUI.ProgressBar関数を呼びます。
今回作成するプログレスバーはプロパティーの変更はないのでプログレスバーを表示して終わりです。
ProgressBarDrawer.cs
using UnityEngine;
namespace UnityEditor
{
[CustomPropertyDrawer(typeof(ProgressBarAttribute))]
public class ProgressBarDrawer : PropertyDrawer
{
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
EditorGUI.ProgressBar(position, property.floatValue, label.text);
}
}
}
プログレスバーを表示する
ProgressBar属性を付ける変数はfloat型にして範囲は0~1の間です。
using UnityEngine;
public class TestScript : MonoBehaviour
{
[ProgressBar]
public float progressBar = 0.5f;
}

以上になります。
非常にシンプルにプログレスバーを表示することができました。
必要な機能があれば付け加えてみてはいかがでしょうか。
関連ページ
こちらのページも合わせてご覧下さい。

【Unity】エディター拡張方法をまとめます!2022/9/21

【Unity】Vector4を1行で表示するエディター拡張を紹介します!2022/7/6

【Unity】ボックスを表示するエディター拡張方法を紹介します!2022/7/18

【Unity】ツールバー表示するエディター拡張方法を紹介します!2022/7/14

【Unity】両端編集可能なスライダーを表示するエディター拡張を紹介します!2022/7/11