soundvision/UnityProject/Assets/Editor/PdBackendEditor.cs

56 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
{
2019-10-01 13:08:35 +00:00
private PdBackend pdBackend_;
2019-10-07 22:03:16 +00:00
private SerializedProperty controlMessageReceivedProperty_;
2019-10-01 13:08:35 +00:00
private readonly string[] samples_ =
{
"No Playback",
"Back_Back",
"Brutal_Synth",
"Dialog",
"Drums",
"Fox_Melo",
"Kick",
"Pads+Strings",
"Rose_Sax",
"Roses_Front"
};
2019-09-29 16:04:26 +00:00
private void Awake()
{
2019-10-01 13:08:35 +00:00
pdBackend_ = (PdBackend) target;
2019-09-29 16:04:26 +00:00
}
public override void OnInspectorGUI ()
{
2019-10-05 12:18:52 +00:00
serializedObject.Update();
2019-10-01 13:08:35 +00:00
pdBackend_ = (PdBackend) target;
2019-10-07 22:03:16 +00:00
controlMessageReceivedProperty_ = serializedObject.FindProperty("controlMessageReceived");
EditorGUILayout.PropertyField(controlMessageReceivedProperty_);
2019-10-05 12:18:52 +00:00
2019-09-29 19:53:47 +00:00
if (Application.isPlaying)
{
2019-10-01 13:08:35 +00:00
RenderSamplePlayback();
2019-09-29 19:53:47 +00:00
Repaint();
}
2019-10-05 12:18:52 +00:00
serializedObject.ApplyModifiedProperties();
2019-09-29 16:04:26 +00:00
}
2019-10-01 13:08:35 +00:00
private void RenderSamplePlayback()
{
GUILayout.Space(5);
pdBackend_.samplePlayback = EditorGUILayout.Popup("Sample File to play", pdBackend_.samplePlayback, samples_);
}
2019-09-29 16:04:26 +00:00
}
}