private void MidiChanged(object tag, int midiindex)
 {
     //Debug.Log("MidiChanged " + midiindex + " for " + tag);
     instance.MPTK_MidiIndex = midiindex;
     instance.MPTK_RePlay();
     MidiCommonEditor.SetSceneChangedIfNeed(instance, true);
 }
        public override void OnInspectorGUI()
        {
            try
            {
                GUI.changed = false;
                GUI.color   = Color.white;
                if (commonEditor == null)
                {
                    commonEditor = ScriptableObject.CreateInstance <MidiCommonEditor>();
                }

                //mDebug.Log(Event.current.type);

                commonEditor.DrawCaption("Midi Stream Player - Create your music with your algo", "https://paxstellar.fr/midi-file-player-detailed-view-2-2/");
                commonEditor.AllPrefab(instance);
                commonEditor.SynthParameters(instance, serializedObject);
#if SHOWDEFAULT
                instance.showDefault = EditorGUILayout.Foldout(instance.showDefault, "Show default editor");
                if (instance.showDefault)
                {
                    EditorGUI.indentLevel++;
                    commonEditor.DrawAlertOnDefault();
                    DrawDefaultInspector();
                    EditorGUI.indentLevel--;
                }
#endif
                MidiCommonEditor.SetSceneChangedIfNeed(instance, GUI.changed);
            }
            catch (System.Exception ex)
            {
                MidiPlayerGlobal.ErrorDetail(ex);
            }
        }
        public override void OnInspectorGUI()
        {
            try
            {
                GUI.changed = false;
                GUI.color   = Color.white;

                if (MidiPlayerGlobal.CurrentMidiSet != null || MidiPlayerGlobal.CurrentMidiSet.MidiFiles == null || MidiPlayerGlobal.CurrentMidiSet.MidiFiles.Count == 0)
                {
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField(new GUIContent("Select Midi ", "Select Midi File to play"), GUILayout.Width(150));

                    if (GUILayout.Button(new GUIContent(instance.MPTK_MidiIndex + " - " + instance.MPTK_MidiName, "Selected Midi File to load"), GUILayout.Height(30)))
                    {
                        InitWinSelectMidi(instance.MPTK_MidiIndex, MidiChanged);
                    }
                    EditorGUILayout.EndHorizontal();

                    instance.MPTK_KeepNoteOff = EditorGUILayout.Toggle(new GUIContent("Keep Midi NoteOff", "Keep Midi NoteOff and NoteOn with Velocity=0 (need to restart the playing Midi)"), instance.MPTK_KeepNoteOff);
                    instance.MPTK_LogEvents   = EditorGUILayout.Toggle(new GUIContent("Log Midi Events", "Log information about each midi events read."), instance.MPTK_LogEvents);

                    EditorGUILayout.BeginHorizontal();
                    if (GUILayout.Button(new GUIContent("Load", "")))
                    {
                        instance.MPTK_Load();
                    }
                    if (GUILayout.Button(new GUIContent("Previous", "")))
                    {
                        instance.MPTK_Previous();
                        instance.MPTK_Load();
                    }
                    if (GUILayout.Button(new GUIContent("Next", "")))
                    {
                        instance.MPTK_Next(); EditorGUILayout.EndHorizontal();
                        instance.MPTK_Load();
                    }

                    EditorGUILayout.EndHorizontal();
                }
                else
                {
                    MidiCommonEditor.ErrorNoMidiFile();
                }

                MidiCommonEditor.SetSceneChangedIfNeed(instance, GUI.changed);
            }
            catch (System.Exception ex)
            {
                MidiPlayerGlobal.ErrorDetail(ex);
            }
        }
        public override void OnInspectorGUI()
        {
            try
            {
                GUI.changed = false;
                GUI.color   = Color.white;
                if (commonEditor == null)
                {
                    commonEditor = ScriptableObject.CreateInstance <MidiCommonEditor>();
                }

                //mDebug.Log(Event.current.type);

                string soundFontSelected = "No SoundFont selected.";
                if (MidiPlayerGlobal.CurrentMidiSet != null && MidiPlayerGlobal.CurrentMidiSet.ActiveSounFontInfo != null)
                {
                    soundFontSelected = MidiPlayerGlobal.CurrentMidiSet.ActiveSounFontInfo.Name;
                    EditorGUILayout.LabelField(new GUIContent("SoundFont: " + soundFontSelected, MidiPlayerGlobal.HelpDefSoundFont));
                    EditorGUILayout.Separator();

                    commonEditor.AllPrefab(instance);
                    commonEditor.SynthParameters(instance, serializedObject);
                }
                else
                {
                    MidiCommonEditor.ErrorNoSoundFont();
                }
#if SHOWDEFAULT
                showDefault = EditorGUILayout.Foldout(showDefault, "Show default editor");
                if (showDefault)
                {
                    EditorGUI.indentLevel++;
                    commonEditor.DrawAlertOnDefault();
                    DrawDefaultInspector();
                    EditorGUI.indentLevel--;
                }
#endif
                MidiCommonEditor.SetSceneChangedIfNeed(instance, GUI.changed);
            }
            catch (System.Exception ex)
            {
                MidiPlayerGlobal.ErrorDetail(ex);
            }
        }
Example #5
0
        public override void OnInspectorGUI()
        {
            try
            {
                //DrawHeader();
                GUI.changed = false;
                GUI.color   = Color.white;
                if (commonEditor == null)
                {
                    commonEditor = ScriptableObject.CreateInstance <MidiCommonEditor>();
                }

                Event e = Event.current;

                commonEditor.DrawCaption("Midi File Player - Play Midi from the MPTK Repository", "https://paxstellar.fr/midi-file-player-detailed-view-2/");

                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField(new GUIContent("Select Midi ", "Select Midi File to play"), GUILayout.Width(150));

                if (MidiPlayerGlobal.CurrentMidiSet.MidiFiles != null && MidiPlayerGlobal.CurrentMidiSet.MidiFiles.Count > 0)
                {
                    if (GUILayout.Button(new GUIContent(instance.MPTK_MidiIndex + " - " + instance.MPTK_MidiName, "Selected Midi File to play"), GUILayout.Height(30)))
                    {
                        InitWinSelectMidi(instance.MPTK_MidiIndex, MidiChanged);
                    }
                }
                else
                {
                    EditorGUILayout.LabelField(MidiPlayerGlobal.ErrorNoMidiFile);
                }
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.Space();

                commonEditor.AllPrefab(instance);
                commonEditor.MidiFileParameters(instance);
                instance.showEvents = MidiCommonEditor.DrawFoldoutAndHelp(instance.showEvents, "Show Midi Events", "https://paxstellar.fr/midi-file-player-detailed-view-2/#Foldout-Events");
                if (instance.showEvents)
                {
                    EditorGUI.indentLevel++;
                    EditorGUILayout.PropertyField(CustomEventStartPlayMidi);
                    EditorGUILayout.PropertyField(CustomEventListNotesEvent);
                    EditorGUILayout.PropertyField(CustomEventEndPlayMidi);
                    serializedObject.ApplyModifiedProperties();
                    EditorGUI.indentLevel--;
                }
                commonEditor.MidiFileInfo(instance);
                commonEditor.SynthParameters(instance, serializedObject);

#if SHOWDEFAULT
                instance.showDefault = EditorGUILayout.Foldout(instance.showDefault, "Show default editor");
                if (instance.showDefault)
                {
                    EditorGUI.indentLevel++;
                    commonEditor.DrawAlertOnDefault();
                    DrawDefaultInspector();
                    EditorGUI.indentLevel--;
                }
#endif
                MidiCommonEditor.SetSceneChangedIfNeed(instance, GUI.changed);
            }
            catch (System.Exception ex)
            {
                MidiPlayerGlobal.ErrorDetail(ex);
            }
        }
        public override void OnInspectorGUI()
        {
            try
            {
                GUI.changed = false;
                GUI.color   = Color.white;
                if (commonEditor == null)
                {
                    commonEditor = ScriptableObject.CreateInstance <MidiCommonEditor>();
                }

                Event e = Event.current;

                string soundFontSelected = "No SoundFont selected.";
                if (MidiPlayerGlobal.CurrentMidiSet != null && MidiPlayerGlobal.CurrentMidiSet.ActiveSounFontInfo != null)
                {
                    soundFontSelected = MidiPlayerGlobal.CurrentMidiSet.ActiveSounFontInfo.Name;
                    EditorGUILayout.LabelField(new GUIContent("SoundFont: " + soundFontSelected, MidiPlayerGlobal.HelpDefSoundFont));
                    EditorGUILayout.Separator();

                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField(new GUIContent("Select Midi ", "Select Midi File to play"), GUILayout.Width(150));

                    if (MidiPlayerGlobal.CurrentMidiSet.MidiFiles != null && MidiPlayerGlobal.CurrentMidiSet.MidiFiles.Count > 0)
                    {
                        if (GUILayout.Button(new GUIContent(instance.MPTK_MidiIndex + " - " + instance.MPTK_MidiName, "Selected Midi File to play"), GUILayout.Height(30)))
                        {
                            InitWinSelectMidi(instance.MPTK_MidiIndex, MidiChanged);
                        }
                    }
                    else
                    {
                        EditorGUILayout.LabelField(MidiPlayerGlobal.ErrorNoMidiFile);
                    }
                    EditorGUILayout.EndHorizontal();
                    EditorGUILayout.Space();

                    commonEditor.AllPrefab(instance);
                    commonEditor.MidiFileParameters(instance);
                    showEvents = EditorGUILayout.Foldout(showEvents, "Show Midi Events");
                    if (showEvents)
                    {
                        EditorGUILayout.PropertyField(CustomEventStartPlayMidi);
                        EditorGUILayout.PropertyField(CustomEventListNotesEvent);
                        EditorGUILayout.PropertyField(CustomEventEndPlayMidi);
                        serializedObject.ApplyModifiedProperties();
                    }
                    commonEditor.MidiFileInfo(instance);
                    commonEditor.SynthParameters(instance, serializedObject);

#if SHOWDEFAULT
                    showDefault = EditorGUILayout.Foldout(showDefault, "Show default editor");
                    if (showDefault)
                    {
                        DrawDefaultInspector();
                    }
#endif
                }
                else
                {
                    MidiCommonEditor.ErrorNoSoundFont();
                }

                MidiCommonEditor.SetSceneChangedIfNeed(instance, GUI.changed);
            }
            catch (System.Exception ex)
            {
                MidiPlayerGlobal.ErrorDetail(ex);
            }
        }