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-26 20:15:30 +00:00
|
|
|
|
private SerializedProperty midiMessageReceivedProperty_;
|
2019-10-27 10:21:33 +00:00
|
|
|
|
private SerializedProperty midiClockReceivedProperty_;
|
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-26 20:15:30 +00:00
|
|
|
|
midiMessageReceivedProperty_ = serializedObject.FindProperty("midiMessageReceived");
|
|
|
|
|
EditorGUILayout.PropertyField(midiMessageReceivedProperty_);
|
2019-10-05 12:18:52 +00:00
|
|
|
|
|
2019-10-27 10:21:33 +00:00
|
|
|
|
midiClockReceivedProperty_ = serializedObject.FindProperty("midiClockReceived");
|
|
|
|
|
EditorGUILayout.PropertyField(midiClockReceivedProperty_);
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
}
|