Files
Continentis/Assets/OtherPlugins/Feel/MMTools/Accessories/MMGUI/MMProgressBarDemoAuto.cs

73 lines
1.9 KiB
C#
Raw Normal View History

2025-10-03 00:02:43 -04:00
using UnityEngine;
#if MM_UI
#endif
namespace MoreMountains.Tools
2026-03-20 11:56:50 -04:00
{
public class MMProgressBarDemoAuto : MonoBehaviour
{
public enum TestModes
{
Permanent,
OneTime
}
2025-10-03 00:02:43 -04:00
2026-03-20 11:56:50 -04:00
public TestModes TestMode = TestModes.Permanent;
2025-10-03 00:02:43 -04:00
2026-03-20 11:56:50 -04:00
[MMEnumCondition("TestMode", (int)TestModes.Permanent)]
public float CurrentValue;
2025-10-03 00:02:43 -04:00
2026-03-20 11:56:50 -04:00
[MMEnumCondition("TestMode", (int)TestModes.Permanent)]
public float MinValue;
2025-10-03 00:02:43 -04:00
2026-03-20 11:56:50 -04:00
[MMEnumCondition("TestMode", (int)TestModes.Permanent)]
public float MaxValue = 100f;
2025-10-03 00:02:43 -04:00
2026-03-20 11:56:50 -04:00
[MMEnumCondition("TestMode", (int)TestModes.Permanent)]
public float Speed = 1f;
2025-10-03 00:02:43 -04:00
2026-03-20 11:56:50 -04:00
[MMEnumCondition("TestMode", (int)TestModes.OneTime)]
public float OneTimeNewValue;
2025-10-03 00:02:43 -04:00
2026-03-20 11:56:50 -04:00
[MMEnumCondition("TestMode", (int)TestModes.OneTime)]
public float OneTimeMinValue;
[MMEnumCondition("TestMode", (int)TestModes.OneTime)]
public float OneTimeMaxValue;
[MMEnumCondition("TestMode", (int)TestModes.OneTime)] [MMInspectorButton("OneTime")]
public bool OneTimeButton;
protected float _direction = 1f;
protected MMProgressBar _progressBar;
protected virtual void Start()
{
Initialization();
}
protected virtual void Update()
{
if (TestMode == TestModes.Permanent)
{
#if MM_UI
_progressBar.UpdateBar(CurrentValue, MinValue, MaxValue);
#endif
CurrentValue += Speed * Time.deltaTime * _direction;
if (CurrentValue <= MinValue || CurrentValue >= MaxValue) _direction *= -1;
}
}
protected virtual void Initialization()
{
_progressBar = GetComponent<MMProgressBar>();
}
protected virtual void OneTime()
{
#if MM_UI
_progressBar.UpdateBar(OneTimeNewValue, OneTimeMinValue, OneTimeMaxValue);
#endif
}
}
2025-10-03 00:02:43 -04:00
}