Exemplo n.º 1
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            Color prev_color = GUI.backgroundColor;

            GUILayout.Space(5f);
            HelmSequencer helmSequencer         = target as HelmSequencer;
            Rect          sequencerPositionRect = GUILayoutUtility.GetRect(minWidth, positionHeight, GUILayout.ExpandWidth(true));
            Rect          rect           = GUILayoutUtility.GetRect(minWidth, sequencerHeight, GUILayout.ExpandWidth(true));
            Rect          velocitiesRect = GUILayoutUtility.GetRect(minWidth, velocitiesHeight, GUILayout.ExpandWidth(true));

            if (sequencer.DoSequencerEvents(rect, helmSequencer, allNotes))
            {
                Repaint();
            }
            if (velocities.DoVelocityEvents(velocitiesRect, helmSequencer, allNotes))
            {
                Repaint();
            }

            sequencerPosition.DrawSequencerPosition(sequencerPositionRect, helmSequencer);
            velocities.DrawSequencerVelocities(velocitiesRect, helmSequencer, allNotes);

            if (rect.height == sequencerHeight)
            {
                sequencer.DrawSequencer(rect, helmSequencer, allNotes);
            }
            GUILayout.Space(5f);
            GUI.backgroundColor = prev_color;

            if (GUILayout.Button(new GUIContent("Clear Sequencer", "Remove all notes from the sequencer.")))
            {
                Undo.RecordObject(helmSequencer, "Clear Sequencer");
                helmSequencer.Clear();
            }

            if (GUILayout.Button(new GUIContent("Load MIDI File [BETA]", "Load a MIDI sequence into this sequencer.")))
            {
                string path = EditorUtility.OpenFilePanel("Load MIDI Sequence", "", "mid");
                if (path.Length != 0)
                {
                    Undo.RecordObject(helmSequencer, "Load MIDI File");
                    helmSequencer.ReadMidiFile(new FileStream(path, FileMode.Open, FileAccess.Read));
                }
            }

            EditorGUILayout.IntSlider(channel, 0, Utils.kMaxChannels - 1);
            EditorGUILayout.IntSlider(length, 1, Sequencer.kMaxLength);
            EditorGUILayout.PropertyField(division);
            serializedObject.ApplyModifiedProperties();
        }
Exemplo n.º 2
0
        int GetChannel()
        {
            HelmController controller = GetComponent <HelmController>();

            if (controller)
            {
                return(controller.channel);
            }

            HelmSequencer sequencer = GetComponent <HelmSequencer>();

            if (sequencer)
            {
                return(sequencer.channel);
            }

            return(0);
        }
Exemplo n.º 3
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            Color prev_color = GUI.backgroundColor;

            GUILayout.Space(5f);
            HelmSequencer helmSequencer         = target as HelmSequencer;
            Rect          sequencerPositionRect = GUILayoutUtility.GetRect(minWidth, positionHeight, GUILayout.ExpandWidth(true));
            Rect          rect = GUILayoutUtility.GetRect(minWidth, sequencerHeight, GUILayout.ExpandWidth(true));

            float startWindow = sequencer.GetMinVisibleTime() / length.intValue;
            float endWindow   = sequencer.GetMaxVisibleTime(rect.width) / length.intValue;

            sequencerPosition.DrawSequencerPosition(sequencerPositionRect, helmSequencer, startWindow, endWindow);

            if (rect.height == sequencerHeight)
            {
                sequencer.DrawSequencer(rect, helmSequencer, zoom.floatValue, allNotes);
            }

            sequencer.DoSequencerEvents(rect, helmSequencer, allNotes);

            GUILayout.Space(5f);
            GUI.backgroundColor = prev_color;

            if (GUILayout.Button(new GUIContent("Clear Sequencer", "Remove all notes from the sequencer.")))
            {
                Undo.RecordObject(helmSequencer, "Clear Sequencer");
                helmSequencer.Clear();
            }

            if (GUILayout.Button(new GUIContent("Load MIDI File [BETA]", "Load a MIDI sequence into this sequencer.")))
            {
                string path = EditorUtility.OpenFilePanel("Load MIDI Sequence", "", "mid");
                if (path.Length != 0)
                {
                    Undo.RecordObject(helmSequencer, "Load MIDI File");
                    helmSequencer.ReadMidiFile(new FileStream(path, FileMode.Open, FileAccess.Read));
                }
            }

            EditorGUILayout.IntSlider(channel, 0, Utils.kMaxChannels - 1);
            EditorGUILayout.PropertyField(length);
            helmSequencer.length = Mathf.Max(helmSequencer.length, 1);

            GUILayout.Space(5f);
            EditorGUILayout.LabelField("View Options", EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(division);
            EditorGUILayout.Slider(zoom, 0.0f, 1.0f);
            EditorGUILayout.PropertyField(autoScroll);


            GUILayout.Space(5f);
            EditorGUILayout.LabelField("Events", EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(noteOnEvent);
            EditorGUILayout.PropertyField(noteOffEvent);
            EditorGUILayout.PropertyField(beatEvent);

            serializedObject.ApplyModifiedProperties();
        }