soundvision/UnityProject/Assets/Editor/SequencerEditor.cs

45 lines
1.6 KiB
C#
Raw Normal View History

2019-10-30 14:01:06 +00:00
using UnityEditor;
using UnityEngine;
namespace cylvester
{
2019-10-30 17:45:05 +00:00
[CustomEditor(typeof(MidiSequencer))]
public class MidiSequencerEditor : Editor
2019-10-30 14:01:06 +00:00
{
2019-10-30 17:45:05 +00:00
private SerializedProperty timeProperty_;
2019-10-30 14:01:06 +00:00
private SerializedProperty sequenceProperty_;
2019-10-30 17:45:05 +00:00
private SerializedProperty callbackProperty_;
private readonly string[] options_ = new string[] {"3", "4", "5", "6"};
2019-10-30 14:01:06 +00:00
private void OnEnable()
2019-10-30 17:45:05 +00:00
{
timeProperty_ = serializedObject.FindProperty("time");
2019-10-30 14:01:06 +00:00
sequenceProperty_ = serializedObject.FindProperty("sequence");
2019-10-30 17:45:05 +00:00
callbackProperty_ = serializedObject.FindProperty("triggered");
2019-10-30 14:01:06 +00:00
}
public override void OnInspectorGUI()
{
serializedObject.Update ();
2019-10-30 17:45:05 +00:00
EditorGUILayout.BeginHorizontal();
EditorGUILayout.LabelField("Time:", GUILayout.Width(120));
timeProperty_.intValue = EditorGUILayout.Popup(timeProperty_.intValue - 3, options_) + 3;
2019-10-30 14:01:06 +00:00
EditorGUILayout.EndHorizontal();
2019-10-30 17:45:05 +00:00
EditorGUILayout.BeginHorizontal();
EditorGUILayout.LabelField("Trigger on:", GUILayout.Width(120));
for (var i = 0; i < 4 * timeProperty_.intValue; ++i)
{
sequenceProperty_.GetArrayElementAtIndex(i).boolValue
= EditorGUILayout.Toggle(sequenceProperty_.GetArrayElementAtIndex(i).boolValue, GUILayout.Width(10));
}
2019-10-30 14:01:06 +00:00
EditorGUILayout.EndHorizontal();
2019-10-30 17:45:05 +00:00
EditorGUILayout.PropertyField(callbackProperty_);
2019-10-30 14:01:06 +00:00
serializedObject.ApplyModifiedProperties ();
}
}
}