//---------------------------------------------------- public override void OnInspectorGUI() { Melody melody = (Melody)target; UnityEditor.EditorGUILayout.LabelField("Add Notes To Melody", UnityEditor.EditorStyles.boldLabel); UnityEditor.EditorGUILayout.BeginHorizontal(); foreach (Note note in Enum.GetValues(typeof(Note))) { if (GUILayout.Button(note.ToString().Replace("Sharp", "#"))) { //Debug.Log($"GUI button {note.ToString().Replace("Sharp", "#")} pressed."); melody.Add(note); } } UnityEditor.EditorGUILayout.EndHorizontal(); GUILayout.Box(melody.ToString()); if (GUILayout.Button("Clear Notes")) { ConfirmationPopupWindow window = CreateInstance <ConfirmationPopupWindow>(); window.Description = "You sure you want to clear this melody?"; window.onResult += HandlePopup; window.ToPosition(); window.ShowPopup(); } }
/// <summary> /// Adds a note to the queue to be played /// </summary> /// <param name="note">The note to be added, which describes the tone and duration to be played.</param> public void AddNote(MusicNote note) { playList.Add(note); }
/// <summary> /// Plays the given frequency indefinitely. /// </summary> /// <param name="frequency">The frequency to play.</param> public void Play(int frequency) { _playList.Clear(); _playList.Add(frequency, int.MaxValue); Play(); }