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))]
|
2019-10-31 09:48:04 +00:00
|
|
|
|
public class PdBackendEditor : UnityEditor.Editor
|
2019-09-29 16:04:26 +00:00
|
|
|
|
{
|
2019-10-01 13:08:35 +00:00
|
|
|
|
private PdBackend pdBackend_;
|
2019-10-26 20:15:30 +00:00
|
|
|
|
private SerializedProperty midiMessageReceivedProperty_;
|
2019-10-30 14:01:06 +00:00
|
|
|
|
private SerializedProperty midiSyncReceivedProperty_;
|
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",
|
2019-10-29 14:42:02 +00:00
|
|
|
|
"Roses_Front",
|
|
|
|
|
"TimbreID_Test"
|
2019-10-01 13:08:35 +00:00
|
|
|
|
};
|
2019-09-29 16:04:26 +00:00
|
|
|
|
|
2019-10-30 17:45:05 +00:00
|
|
|
|
private void OnEnable()
|
2019-09-29 16:04:26 +00:00
|
|
|
|
{
|
2019-10-01 13:08:35 +00:00
|
|
|
|
pdBackend_ = (PdBackend) target;
|
2019-10-30 17:45:05 +00:00
|
|
|
|
midiMessageReceivedProperty_ = serializedObject.FindProperty("midiMessageReceived");
|
|
|
|
|
midiSyncReceivedProperty_ = serializedObject.FindProperty("midiSyncReceived");
|
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
|
|
|
|
EditorGUILayout.PropertyField(midiMessageReceivedProperty_);
|
2019-10-30 14:01:06 +00:00
|
|
|
|
EditorGUILayout.PropertyField(midiSyncReceivedProperty_);
|
2019-10-27 10:21:33 +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
|
|
|
|
}
|
|
|
|
|
}
|