55 lines
825 B
C#
55 lines
825 B
C#
using System;
|
|
using UnityEngine;
|
|
|
|
namespace EnergyBarToolkit
|
|
{
|
|
[ExecuteInEditMode]
|
|
public class MultiBarSliders : MonoBehaviour
|
|
{
|
|
[Serializable]
|
|
public class Bar
|
|
{
|
|
public EnergyBar bar;
|
|
|
|
public string label = "Edit Me!";
|
|
}
|
|
|
|
public Bar[] bars;
|
|
|
|
public Rect area = new Rect(10f, 10f, 140f, 400f);
|
|
|
|
private void Start()
|
|
{
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
}
|
|
|
|
private void OnGUI()
|
|
{
|
|
if (bars == null)
|
|
{
|
|
return;
|
|
}
|
|
GUILayout.BeginArea(area);
|
|
Bar[] array = bars;
|
|
foreach (Bar bar in array)
|
|
{
|
|
GUILayout.Label(bar.label);
|
|
float value = 0f;
|
|
if (bar.bar != null)
|
|
{
|
|
value = bar.bar.ValueF;
|
|
}
|
|
value = GUILayout.HorizontalSlider(value, 0f, 1f);
|
|
if (Application.isPlaying)
|
|
{
|
|
bar.bar.ValueF = value;
|
|
}
|
|
}
|
|
GUILayout.EndArea();
|
|
}
|
|
}
|
|
}
|