예제 #1
0
    void Awake()
    {
        controls = new InputMaster();

        // define all controls / interaction / etc
        controls.Gameplay.Move.performed += ctx => moveVector = ctx.ReadValue <Vector2>();
        controls.Gameplay.Move.canceled  += ctx => moveVector = Vector2.zero;

        controls.Gameplay.Run.performed += ctx => isRunning = true;
        controls.Gameplay.Run.canceled  += ctx => isRunning = false;

        controls.Gameplay.Interact.performed += ctx => StartInteract();
        // this needs to be handled better way. This is buggy
        // controls.Gameplay.Interact.performed += ctx => StopInteract();

        helmSampler = transform.Find("FootSteps").GetComponent <AudioHelm.Sampler>();
    }
예제 #2
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            Color prev_color = GUI.backgroundColor;

            GUILayout.Space(5f);
            SampleSequencer sampleSequencer = target as SampleSequencer;
            Sampler         sampler         = sampleSequencer.GetComponent <Sampler>();

            if (sampler)
            {
                sequencer.minKey = sampler.GetMinKey();
                sequencer.maxKey = sampler.GetMaxKey();
            }
            else
            {
                sequencer.minKey = 0;
                sequencer.maxKey = Utils.kMidiSize - 1;
            }

            Rect  sequencerPositionRect = GUILayoutUtility.GetRect(minWidth, positionHeight, GUILayout.ExpandWidth(true));
            float seqHeight             = Mathf.Min(sequencerHeight, sequencer.GetMaxHeight());
            Rect  rect           = GUILayoutUtility.GetRect(minWidth, seqHeight, GUILayout.ExpandWidth(true));
            Rect  velocitiesRect = GUILayoutUtility.GetRect(minWidth, velocitiesHeight, GUILayout.ExpandWidth(true));

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

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

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

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

                for (int i = 0; i < allNotes.arraySize; ++i)
                {
                    SerializedProperty noteRow = allNotes.GetArrayElementAtIndex(i);
                    SerializedProperty notes   = noteRow.FindPropertyRelative("notes");
                    notes.ClearArray();
                }
                sampleSequencer.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(sampleSequencer, "Load MIDI File");
                    sampleSequencer.ReadMidiFile(new FileStream(path, FileMode.Open, FileAccess.Read));
                }
            }

            EditorGUILayout.IntSlider(length, 1, Sequencer.kMaxLength);
            EditorGUILayout.PropertyField(division);
            serializedObject.ApplyModifiedProperties();
        }
예제 #3
0
 void MouseUp(float key, int row, Sampler sampler)
 {
     currentKeyzone = null;
 }
예제 #4
0
 public int GetHeight(Sampler sampler)
 {
     return(keyboardHeight + rowHeight * sampler.keyzones.Count + scrollWidth);
 }
예제 #5
0
        void DrawClips(Sampler sampler, SerializedProperty keyzones)
        {
            int      height = rowHeight / 2;
            GUIStyle style  = new GUIStyle(GUI.skin.button);

            style.padding  = new RectOffset(0, 0, 0, 0);
            style.fontSize = height - 4;
            int y = keyboardHeight;

            Keyzone remove = null;

            foreach (Keyzone keyzone in sampler.keyzones)
            {
                Rect buttonRect = new Rect(0, y, height, height);
                Rect clipRect   = new Rect(buttonRect.xMax, y, keyzoneWidth - velocityWidth - buttonRect.width, height);
                Rect mixerRect  = new Rect(buttonRect.xMax, y + height, keyzoneWidth - velocityWidth - buttonRect.width, height);

                if (GUI.Button(buttonRect, "X", style))
                {
                    remove = keyzone;
                }

                AudioClip clip = EditorGUI.ObjectField(clipRect, keyzone.audioClip, typeof(AudioClip), false)
                                 as AudioClip;
                AudioMixerGroup mixer = EditorGUI.ObjectField(mixerRect, keyzone.mixer, typeof(AudioMixerGroup), false)
                                        as AudioMixerGroup;

                Rect  velocityMinRect = new Rect(clipRect.xMax, y, velocityWidth, height);
                Rect  velocityMaxRect = new Rect(mixerRect.xMax, y + height, velocityWidth, height);
                float minVelocity     = Mathf.Clamp(EditorGUI.FloatField(velocityMinRect, keyzone.minVelocity), 0.0f, 1.0f);
                float maxVelocity     = Mathf.Clamp(EditorGUI.FloatField(velocityMaxRect, keyzone.maxVelocity), 0.0f, 1.0f);

                if (clip != keyzone.audioClip)
                {
                    if (clip == null)
                    {
                        Undo.RecordObject(sampler, "Remove AudioClip from Keyzone");
                    }
                    else
                    {
                        Undo.RecordObject(sampler, "Change AudioClip in Keyzone");
                    }
                    keyzone.audioClip = clip;
                }
                if (mixer != keyzone.mixer)
                {
                    if (mixer == null)
                    {
                        Undo.RecordObject(sampler, "Remove AudioMixerGroup from Keyzone");
                    }
                    else
                    {
                        Undo.RecordObject(sampler, "Change AudioMixerGroup in Keyzone");
                    }
                    keyzone.mixer = mixer;
                }
                if (minVelocity != keyzone.minVelocity)
                {
                    Undo.RecordObject(sampler, "Change Keyzone Minimum Velocity");
                    keyzone.minVelocity = minVelocity;
                }
                if (maxVelocity != keyzone.maxVelocity)
                {
                    Undo.RecordObject(sampler, "Change Keyzone Maximum Velocity");
                    keyzone.maxVelocity = maxVelocity;
                }
                y += rowHeight;
            }

            if (remove != null)
            {
                Undo.RecordObject(sampler, "Delete Keyzone");
                int index = sampler.RemoveKeyzone(remove);
                if (index >= 0)
                {
                    keyzones.DeleteArrayElementAtIndex(index);
                }
            }
        }
예제 #6
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            Color prev_color = GUI.backgroundColor;

            GUILayout.Space(5f);
            SampleSequencer sampleSequencer = target as SampleSequencer;
            Sampler         sampler         = sampleSequencer.GetComponent <Sampler>();

            if (sampler)
            {
                sequencer.minKey = sampler.GetMinKey();
                sequencer.maxKey = sampler.GetMaxKey();
            }
            else
            {
                sequencer.minKey = 0;
                sequencer.maxKey = Utils.kMidiSize - 1;
            }

            Rect  sequencerPositionRect = GUILayoutUtility.GetRect(minWidth, positionHeight, GUILayout.ExpandWidth(true));
            float seqHeight             = Mathf.Min(sequencerHeight, sequencer.GetMaxHeight());
            Rect  rect = GUILayoutUtility.GetRect(minWidth, seqHeight, GUILayout.ExpandWidth(true));

            sequencer.DoSequencerEvents(rect, sampleSequencer, allNotes);

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

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

            if (rect.height == seqHeight)
            {
                sequencer.DrawSequencer(rect, sampleSequencer, zoom.floatValue, allNotes);
            }
            GUILayout.Space(5f);
            GUI.backgroundColor = prev_color;

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

                for (int i = 0; i < allNotes.arraySize; ++i)
                {
                    SerializedProperty noteRow = allNotes.GetArrayElementAtIndex(i);
                    SerializedProperty notes   = noteRow.FindPropertyRelative("notes");
                    notes.ClearArray();
                }
                sampleSequencer.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(sampleSequencer, "Load MIDI File");
                    sampleSequencer.ReadMidiFile(new FileStream(path, FileMode.Open, FileAccess.Read));
                }
            }

            EditorGUILayout.PropertyField(length);
            sampleSequencer.length = Mathf.Max(sampleSequencer.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();
        }