soundvision/UnityProject/Assets/Editor/PdBackendEditor.cs

49 lines
1.4 KiB
C#
Raw Normal View History

2019-09-29 19:53:47 +00:00
using UnityEditor;
2019-09-29 16:04:26 +00:00
using UnityEngine;
namespace cylvester
{
[CustomEditor(typeof(PdBackend))]
public class PdBackendEditor : Editor
{
private IPdBackend pdBackend_;
private ILevelMeter[] levelMeters_;
private readonly string[] channels = {
"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16"
};
private void Awake()
{
pdBackend_ = (IPdBackend) target;
levelMeters_ = new ILevelMeter[16];
for (var i = 0; i < 16; ++i)
2019-09-29 19:53:47 +00:00
levelMeters_[i] = new LevelMeter(i);
2019-09-29 16:04:26 +00:00
}
public override void OnInspectorGUI ()
{
pdBackend_ = (IPdBackend) target;
GUILayout.Space(5);
GUILayout.BeginHorizontal();
GUILayout.Label("Main Patch");
pdBackend_.MainPatch = GUILayout.TextField(pdBackend_.MainPatch, 30);
GUILayout.EndHorizontal();
pdBackend_.NumInputChannels = EditorGUILayout.Popup("Number of input channels", pdBackend_.NumInputChannels, channels);
2019-09-29 19:53:47 +00:00
if (Application.isPlaying)
{
2019-09-29 16:04:26 +00:00
2019-09-29 19:53:47 +00:00
GUILayout.Space(5);
GUILayout.BeginHorizontal();
foreach (var levelMeter in levelMeters_)
levelMeter.Render(pdBackend_.LevelMeterArray);
GUILayout.EndHorizontal();
2019-09-29 16:04:26 +00:00
2019-09-29 19:53:47 +00:00
Repaint();
}
2019-09-29 16:04:26 +00:00
}
}
}