Added Feel plugin
This commit is contained in:
189
Assets/External/Feel/MMFeedbacks/Editor/Sequencing/MMInputSequenceRecorderEditor.cs
vendored
Normal file
189
Assets/External/Feel/MMFeedbacks/Editor/Sequencing/MMInputSequenceRecorderEditor.cs
vendored
Normal file
@@ -0,0 +1,189 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MoreMountains.Feedbacks
|
||||
{
|
||||
/// <summary>
|
||||
/// Custom editor for sequence recorder
|
||||
/// </summary>
|
||||
[CustomEditor(typeof(MMInputSequenceRecorder), true)]
|
||||
[CanEditMultipleObjects]
|
||||
public class MMInputSequenceRecorderEditor : Editor
|
||||
{
|
||||
protected SerializedProperty _Recording;
|
||||
protected float _inspectorWidth;
|
||||
protected int _externalMargin = 10;
|
||||
protected Rect _rect;
|
||||
protected Color _recordingColor = Color.red;
|
||||
protected Color _recordingTextColor = Color.white;
|
||||
protected Vector2 _boxPosition;
|
||||
protected Vector2 _boxSize;
|
||||
protected GUIStyle _recordingStyle;
|
||||
protected MMInputSequenceRecorder _targetRecorder;
|
||||
protected Event _currentEvent;
|
||||
|
||||
/// <summary>
|
||||
/// Forces constant inspector repaints
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override bool RequiresConstantRepaint()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// On enable we initialize our styles and listen for input in editor mode
|
||||
/// </summary>
|
||||
protected virtual void OnEnable()
|
||||
{
|
||||
_Recording = serializedObject.FindProperty("Recording");
|
||||
|
||||
_recordingStyle = new GUIStyle();
|
||||
_recordingStyle.normal.textColor = Color.white;
|
||||
_recordingStyle.fontSize = 30;
|
||||
_recordingStyle.alignment = TextAnchor.MiddleCenter;
|
||||
_targetRecorder = (MMInputSequenceRecorder)target;
|
||||
|
||||
System.Reflection.FieldInfo info = typeof(EditorApplication).GetField("globalEventHandler", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic);
|
||||
EditorApplication.CallbackFunction value = (EditorApplication.CallbackFunction)info.GetValue(null);
|
||||
value += EditorGlobalKeyPress;
|
||||
info.SetValue(null, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks for input
|
||||
/// </summary>
|
||||
protected virtual void EditorGlobalKeyPress()
|
||||
{
|
||||
if (Application.isPlaying)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
HandleUtility.AddDefaultControl(GUIUtility.GetControlID(FocusType.Passive));
|
||||
_currentEvent = Event.current;
|
||||
|
||||
if (_currentEvent == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
DetectStartAndEnd();
|
||||
EditorDetectRecording();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Detects presses on the start or end keys
|
||||
/// </summary>
|
||||
protected virtual void DetectStartAndEnd()
|
||||
{
|
||||
if (_currentEvent.isKey)
|
||||
{
|
||||
if (!_targetRecorder.Recording)
|
||||
{
|
||||
if ((_currentEvent.keyCode == _targetRecorder.StartRecordingHotkey) && (_currentEvent.type == EventType.KeyDown))
|
||||
{
|
||||
_targetRecorder.StartRecording();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((_currentEvent.keyCode == _targetRecorder.StopRecordingHotkey) && (_currentEvent.type == EventType.KeyDown))
|
||||
{
|
||||
_targetRecorder.StopRecording();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks for key presses on sequence key bindings
|
||||
/// </summary>
|
||||
protected virtual void EditorDetectRecording()
|
||||
{
|
||||
if (_targetRecorder.Recording && (_targetRecorder.SequenceScriptableObject != null))
|
||||
{
|
||||
if (_currentEvent.isKey)
|
||||
{
|
||||
foreach (MMSequenceTrack track in _targetRecorder.SequenceScriptableObject.SequenceTracks)
|
||||
{
|
||||
if (_currentEvent.keyCode == (track.Key))
|
||||
{
|
||||
if (track.State == MMSequenceTrackStates.Up)
|
||||
{
|
||||
track.State = MMSequenceTrackStates.Idle;
|
||||
}
|
||||
if (_currentEvent.type == EventType.KeyDown)
|
||||
{
|
||||
if (track.State != MMSequenceTrackStates.Down)
|
||||
{
|
||||
// key is down for the first time
|
||||
_targetRecorder.AddNoteToTrack(track);
|
||||
}
|
||||
track.State = MMSequenceTrackStates.Down;
|
||||
}
|
||||
if (_currentEvent.type == EventType.KeyUp)
|
||||
{
|
||||
// key is up
|
||||
track.State = MMSequenceTrackStates.Up;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draws the custom inspector
|
||||
/// </summary>
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
Undo.RecordObject(target, "Modified Sequence Recorder");
|
||||
|
||||
_inspectorWidth = EditorGUIUtility.currentViewWidth - 24;
|
||||
|
||||
// display recording label
|
||||
if (_Recording.boolValue)
|
||||
{
|
||||
GUILayout.Box("", GUILayout.Width(_inspectorWidth - _externalMargin), GUILayout.Height(50));
|
||||
_boxPosition = GUILayoutUtility.GetLastRect().position;
|
||||
_boxSize = GUILayoutUtility.GetLastRect().size;
|
||||
_rect.x = _boxPosition.x;
|
||||
_rect.y = _boxPosition.y;
|
||||
_rect.width = _boxSize.x;
|
||||
_rect.height = _boxSize.y;
|
||||
EditorGUI.DrawRect(_rect, _recordingColor);
|
||||
|
||||
EditorGUI.LabelField(_rect, "RECORDING", _recordingStyle);
|
||||
}
|
||||
|
||||
DrawDefaultInspector();
|
||||
|
||||
// separator
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.LabelField("Controls", EditorStyles.boldLabel);
|
||||
|
||||
if (!_Recording.boolValue)
|
||||
{
|
||||
// display start recording button
|
||||
if (GUILayout.Button("Start Recording"))
|
||||
{
|
||||
_targetRecorder.StartRecording();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// display stop recording button
|
||||
if (GUILayout.Button("Stop Recording"))
|
||||
{
|
||||
_targetRecorder.StopRecording();
|
||||
}
|
||||
}
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
18
Assets/External/Feel/MMFeedbacks/Editor/Sequencing/MMInputSequenceRecorderEditor.cs.meta
vendored
Normal file
18
Assets/External/Feel/MMFeedbacks/Editor/Sequencing/MMInputSequenceRecorderEditor.cs.meta
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 356e077c6b0c8614fa08b93f8099bedf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 183370
|
||||
packageName: Feel
|
||||
packageVersion: 5.9.1
|
||||
assetPath: Assets/Feel/MMFeedbacks/Editor/Sequencing/MMInputSequenceRecorderEditor.cs
|
||||
uploadId: 830868
|
||||
418
Assets/External/Feel/MMFeedbacks/Editor/Sequencing/MMSequencerEditor.cs
vendored
Normal file
418
Assets/External/Feel/MMFeedbacks/Editor/Sequencing/MMSequencerEditor.cs
vendored
Normal file
@@ -0,0 +1,418 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MoreMountains.Feedbacks
|
||||
{
|
||||
/// <summary>
|
||||
/// Custom editor for MMSequencer, handles recalibration and sequencer display
|
||||
/// </summary>
|
||||
[CustomEditor(typeof(MMSequencer), true)]
|
||||
[CanEditMultipleObjects]
|
||||
public class MMSequencerEditor : Editor
|
||||
{
|
||||
protected MMSequencer _targetSequencer;
|
||||
protected float _inspectorWidth;
|
||||
protected GUIStyle _buttonStyle;
|
||||
protected GUIStyle _trackControlStyle;
|
||||
protected GUIStyle _indexStyle;
|
||||
protected Texture2D _buttonBackground;
|
||||
protected Texture2D _dotBackground;
|
||||
protected Color _buttonColor;
|
||||
protected Color _trackControlColor;
|
||||
|
||||
protected Color _emptyButtonColor = new Color(0,0,0,0.5f);
|
||||
protected Color _empty4ButtonColor = new Color(0, 0, 0, 0.75f);
|
||||
protected const float _buttonWidth = 24;
|
||||
protected const float _trackControlWidth = 11;
|
||||
protected const float _distanceBetweenButtons = 6f;
|
||||
protected int _boxesPerLine;
|
||||
protected Color _originalBackgroundColor;
|
||||
protected Color _controlColor;
|
||||
|
||||
protected List<float> _trackControlLastUseTimestamps;
|
||||
|
||||
/// <summary>
|
||||
/// We want constant repaint on this inspector
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override bool RequiresConstantRepaint()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// On enable we grab our textures and initialize our styles
|
||||
/// </summary>
|
||||
protected virtual void OnEnable()
|
||||
{
|
||||
_targetSequencer = (MMSequencer)target;
|
||||
_buttonBackground = Resources.Load("SequencerButtonBackground") as Texture2D;
|
||||
_dotBackground = Resources.Load("SequencerDotBackground") as Texture2D;
|
||||
_originalBackgroundColor = GUI.backgroundColor;
|
||||
|
||||
_buttonStyle = new GUIStyle();
|
||||
_buttonStyle.normal.background = _buttonBackground;
|
||||
_buttonStyle.fixedWidth = _buttonWidth;
|
||||
_buttonStyle.fixedHeight = _buttonWidth;
|
||||
|
||||
_trackControlStyle = new GUIStyle();
|
||||
_trackControlStyle.normal.background = _dotBackground;
|
||||
_trackControlStyle.normal.textColor = (Application.isPlaying) ? Color.black : Color.white;
|
||||
_trackControlStyle.fixedWidth = _trackControlWidth;
|
||||
_trackControlStyle.fixedHeight = _trackControlWidth;
|
||||
_trackControlStyle.margin = new RectOffset(0, 0, 1, 0);
|
||||
_trackControlStyle.alignment = TextAnchor.MiddleCenter;
|
||||
_trackControlStyle.fontSize = 10;
|
||||
|
||||
|
||||
_indexStyle = new GUIStyle();
|
||||
_indexStyle.normal.background = _dotBackground;
|
||||
_indexStyle.normal.textColor = Color.white;
|
||||
_indexStyle.alignment = TextAnchor.MiddleCenter;
|
||||
_indexStyle.fixedWidth = _trackControlWidth * 1.5f;
|
||||
_indexStyle.fixedHeight = _trackControlWidth * 1.5f;
|
||||
|
||||
FillControlList();
|
||||
}
|
||||
|
||||
protected virtual void FillControlList()
|
||||
{
|
||||
// fill the control timer list
|
||||
if (_targetSequencer.Sequence != null)
|
||||
{
|
||||
_trackControlLastUseTimestamps = new List<float>();
|
||||
foreach (MMSequenceTrack track in _targetSequencer.Sequence.SequenceTracks)
|
||||
{
|
||||
_trackControlLastUseTimestamps.Add(0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draws the default inspector and the sequencer
|
||||
/// </summary>
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
Undo.RecordObject(target, "Modified Sequence Recorder");
|
||||
|
||||
DrawDefaultInspector();
|
||||
|
||||
if (_targetSequencer.Sequence == null)
|
||||
{
|
||||
_targetSequencer.LastSequence = null;
|
||||
return;
|
||||
}
|
||||
|
||||
// gets the width and computes how many boxes we can fit per line
|
||||
_inspectorWidth = EditorGUIUtility.currentViewWidth - 24;
|
||||
_boxesPerLine = (int)Mathf.Round(
|
||||
(_inspectorWidth - ((_targetSequencer.Sequence.SequenceTracks.Count) * _distanceBetweenButtons) - _trackControlWidth - _distanceBetweenButtons)
|
||||
/ (_buttonWidth + _distanceBetweenButtons)
|
||||
) + 1;
|
||||
|
||||
LookForChanges();
|
||||
|
||||
// separator
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.LabelField("Sequencer", EditorStyles.boldLabel);
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
if (GUILayout.Button("Destroy and rebuild sequence", EditorStyles.miniButtonLeft))
|
||||
{
|
||||
_targetSequencer.Sequence.QuantizedSequence = null;
|
||||
_targetSequencer.LastTracksCount = -1;
|
||||
_targetSequencer.ApplySequencerLengthToSequence();
|
||||
EditorUtility.SetDirty(_targetSequencer.Sequence);
|
||||
}
|
||||
if (GUILayout.Button("Clear Sequence", EditorStyles.miniButtonMid))
|
||||
{
|
||||
_targetSequencer.ClearSequence();
|
||||
EditorUtility.SetDirty(_targetSequencer.Sequence);
|
||||
}
|
||||
if (GUILayout.Button("[ - ] Length - 1", EditorStyles.miniButtonMid))
|
||||
{
|
||||
_targetSequencer.DecrementLength();
|
||||
EditorUtility.SetDirty(_targetSequencer.Sequence);
|
||||
}
|
||||
if (GUILayout.Button("[ + ] Length + 1", EditorStyles.miniButtonRight))
|
||||
{
|
||||
_targetSequencer.IncrementLength();
|
||||
EditorUtility.SetDirty(_targetSequencer.Sequence);
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.Space();
|
||||
DrawSequenceIndexes();
|
||||
for (int i = 0; i < _targetSequencer.Sequence.SequenceTracks.Count; i++)
|
||||
{
|
||||
DrawTrack(i);
|
||||
}
|
||||
|
||||
DrawControlButtons();
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whenever we detect a change in the settings we recalibrate our sequence accordingly
|
||||
/// </summary>
|
||||
protected virtual void LookForChanges()
|
||||
{
|
||||
if (_targetSequencer.LastSequence != _targetSequencer.Sequence)
|
||||
{
|
||||
FillControlList();
|
||||
if (_targetSequencer.Sequence.QuantizedSequence.Count > 0)
|
||||
{
|
||||
if (_targetSequencer.Sequence.QuantizedSequence[0].Line.Count != _targetSequencer.SequencerLength)
|
||||
{
|
||||
_targetSequencer.SequencerLength = _targetSequencer.Sequence.QuantizedSequence[0].Line.Count;
|
||||
_targetSequencer.LastSequencerLength = _targetSequencer.SequencerLength;
|
||||
_targetSequencer.LastSequence = _targetSequencer.Sequence;
|
||||
_targetSequencer.LastTracksCount = _targetSequencer.Sequence.SequenceTracks.Count;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_targetSequencer.ApplySequencerLengthToSequence();
|
||||
_targetSequencer.LastSequence = _targetSequencer.Sequence;
|
||||
EditorUtility.SetDirty(_targetSequencer.Sequence);
|
||||
}
|
||||
}
|
||||
|
||||
if (_targetSequencer.LastSequence == _targetSequencer.Sequence)
|
||||
{
|
||||
if (_targetSequencer.LastTracksCount != _targetSequencer.Sequence.SequenceTracks.Count)
|
||||
{
|
||||
FillControlList();
|
||||
_targetSequencer.ApplySequencerLengthToSequence();
|
||||
EditorUtility.SetDirty(_targetSequencer.Sequence);
|
||||
}
|
||||
if (_targetSequencer.LastBPM != _targetSequencer.BPM)
|
||||
{
|
||||
_targetSequencer.UpdateTimestampsToMatchNewBPM();
|
||||
EditorUtility.SetDirty(_targetSequencer.Sequence);
|
||||
}
|
||||
}
|
||||
|
||||
_targetSequencer.EditorMaintenance();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draws control buttons
|
||||
/// </summary>
|
||||
protected virtual void DrawControlButtons()
|
||||
{
|
||||
if (!Application.isPlaying)
|
||||
{
|
||||
return;
|
||||
}
|
||||
GUI.backgroundColor = _originalBackgroundColor;
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.LabelField("Controls", EditorStyles.boldLabel);
|
||||
|
||||
if (_targetSequencer.Playing)
|
||||
{
|
||||
if (GUILayout.Button("Stop Playing"))
|
||||
{
|
||||
_targetSequencer.StopSequence();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (GUILayout.Button("Start Playing"))
|
||||
{
|
||||
_targetSequencer.PlaySequence();
|
||||
}
|
||||
}
|
||||
if (GUILayout.Button("Play Next Beat"))
|
||||
{
|
||||
_targetSequencer.PlayBeat();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draws an index for each sequence item
|
||||
/// </summary>
|
||||
protected virtual void DrawSequenceIndexes()
|
||||
{
|
||||
GUILayout.BeginHorizontal();
|
||||
|
||||
GUI.backgroundColor = _emptyButtonColor;
|
||||
GUILayout.Label("", GUILayout.Width(_trackControlWidth + _distanceBetweenButtons), GUILayout.Height(_trackControlWidth));
|
||||
string label = "";
|
||||
for (int i = 0; i < _targetSequencer.SequencerLength; i++)
|
||||
{
|
||||
label = i < 10 ? " " + i.ToString() : i.ToString();
|
||||
_trackControlStyle.fontStyle = (i % 4 == 0) ? FontStyle.Bold : FontStyle.Normal;
|
||||
//GUILayout.Label(label, _indexStyle, GUILayout.Width(_buttonWidth + _distanceBetweenButtons), GUILayout.Height(_trackControlWidth));
|
||||
if (GUILayout.Button(label, _indexStyle, GUILayout.Width(_buttonWidth + _distanceBetweenButtons), GUILayout.Height(_trackControlWidth)))
|
||||
{
|
||||
_targetSequencer.ToggleStep(i);
|
||||
EditorUtility.SetDirty(_targetSequencer.Sequence);
|
||||
}
|
||||
}
|
||||
GUI.backgroundColor = _originalBackgroundColor;
|
||||
GUILayout.EndHorizontal();
|
||||
GUILayout.Space(_distanceBetweenButtons * 1.5f);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draws a line of the sequencer
|
||||
/// </summary>
|
||||
/// <param name="trackIndex"></param>
|
||||
protected virtual void DrawTrack(int trackIndex)
|
||||
{
|
||||
int counter = 0;
|
||||
|
||||
if (_targetSequencer.Sequence.QuantizedSequence == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_targetSequencer.Sequence.QuantizedSequence.Count != _targetSequencer.Sequence.SequenceTracks.Count)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
|
||||
|
||||
GUILayout.BeginVertical();
|
||||
|
||||
// draw active track control
|
||||
|
||||
if (_targetSequencer.Sequence.SequenceTracks[trackIndex].Active)
|
||||
{
|
||||
_trackControlColor = _targetSequencer.Sequence.SequenceTracks[trackIndex].TrackColor;
|
||||
}
|
||||
else
|
||||
{
|
||||
_trackControlColor = _emptyButtonColor;
|
||||
}
|
||||
|
||||
GUI.backgroundColor = _trackControlColor;
|
||||
if (GUILayout.Button("", _trackControlStyle, GUILayout.Width(_trackControlWidth), GUILayout.Height(_trackControlWidth)))
|
||||
{
|
||||
if (_targetSequencer.TrackEvents[trackIndex] != null)
|
||||
{
|
||||
_targetSequencer.ToggleActive(trackIndex);
|
||||
EditorUtility.SetDirty(_targetSequencer.Sequence);
|
||||
}
|
||||
}
|
||||
|
||||
GUILayout.Space(_distanceBetweenButtons / 5);
|
||||
|
||||
// draw test track control
|
||||
_trackControlColor = _targetSequencer.Sequence.SequenceTracks[trackIndex].TrackColor;
|
||||
_controlColor = Application.isPlaying ? SequencerColor(_trackControlLastUseTimestamps[trackIndex], _trackControlColor) : Color.black;
|
||||
GUI.backgroundColor = _controlColor;
|
||||
if (GUILayout.Button(trackIndex.ToString(), _trackControlStyle, GUILayout.Width(_trackControlWidth), GUILayout.Height(_trackControlWidth)))
|
||||
{
|
||||
if (_targetSequencer.TrackEvents[trackIndex] != null)
|
||||
{
|
||||
_trackControlLastUseTimestamps[trackIndex] = Time.time;
|
||||
_targetSequencer.PlayTrackEvent(trackIndex);
|
||||
}
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
|
||||
GUILayout.Space(_distanceBetweenButtons);
|
||||
|
||||
for (int i = 0; i < _targetSequencer.Sequence.QuantizedSequence[trackIndex].Line.Count; i++)
|
||||
{
|
||||
// handle new lines
|
||||
if (counter > _boxesPerLine )
|
||||
{
|
||||
GUILayout.EndHorizontal();
|
||||
GUILayout.Space(_distanceBetweenButtons);
|
||||
GUILayout.BeginHorizontal();
|
||||
counter = 0;
|
||||
}
|
||||
|
||||
if (_targetSequencer.Sequence.QuantizedSequence[trackIndex].Line[i].ID != -1)
|
||||
{
|
||||
_buttonColor = _targetSequencer.Sequence.SequenceTracks[trackIndex].TrackColor;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (i % 4 == 0)
|
||||
{
|
||||
_buttonColor = _empty4ButtonColor;
|
||||
}
|
||||
else
|
||||
{
|
||||
_buttonColor = _emptyButtonColor;
|
||||
}
|
||||
}
|
||||
// if the track is inactive, we reduce colors
|
||||
if (!_targetSequencer.Sequence.SequenceTracks[trackIndex].Active)
|
||||
{
|
||||
_buttonColor = _buttonColor / 2f;
|
||||
}
|
||||
|
||||
DrawSequenceButton(trackIndex, i, _buttonColor);
|
||||
|
||||
counter++;
|
||||
}
|
||||
GUILayout.FlexibleSpace();
|
||||
GUILayout.EndHorizontal();
|
||||
GUILayout.Space(_distanceBetweenButtons);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draws an interactive button for the sequencer
|
||||
/// </summary>
|
||||
/// <param name="trackIndex"></param>
|
||||
/// <param name="sequenceIndex"></param>
|
||||
/// <param name="buttonColor"></param>
|
||||
protected virtual void DrawSequenceButton(int trackIndex, int sequenceIndex, Color buttonColor)
|
||||
{
|
||||
|
||||
if (Application.isPlaying && _targetSequencer.PlayedOnce && (_targetSequencer.LastBeatIndex == sequenceIndex))
|
||||
{
|
||||
if (_targetSequencer.BeatThisFrame)
|
||||
{
|
||||
_buttonColor = Color.white;
|
||||
}
|
||||
else
|
||||
{
|
||||
_buttonColor = SequencerColor(_targetSequencer.LastBeatTimestamp, buttonColor);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_buttonColor = buttonColor;
|
||||
}
|
||||
|
||||
GUI.backgroundColor = _buttonColor;
|
||||
if (GUILayout.Button("", _buttonStyle, GUILayout.Width(_buttonWidth), GUILayout.Height(_buttonWidth)))
|
||||
{
|
||||
bool active = (_targetSequencer.Sequence.QuantizedSequence[trackIndex].Line[sequenceIndex].ID == _targetSequencer.Sequence.SequenceTracks[trackIndex].ID);
|
||||
_targetSequencer.Sequence.QuantizedSequence[trackIndex].Line[sequenceIndex].ID = active ? -1 : _targetSequencer.Sequence.SequenceTracks[trackIndex].ID;
|
||||
EditorUtility.SetDirty(_targetSequencer.Sequence);
|
||||
}
|
||||
GUILayout.Space(_distanceBetweenButtons);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Color interpolation on hits
|
||||
/// </summary>
|
||||
/// <param name="lastBeatTimestamp"></param>
|
||||
/// <param name="buttonColor"></param>
|
||||
/// <returns></returns>
|
||||
protected virtual Color SequencerColor(float lastBeatTimestamp, Color buttonColor)
|
||||
{
|
||||
float x = (Time.time - lastBeatTimestamp);
|
||||
float A = 0f;
|
||||
float B = (60f / _targetSequencer.BPM) / 4f;
|
||||
float C = 0f;
|
||||
float D = 1f;
|
||||
float t = C + (x - A) / (B - A) * (D - C);
|
||||
return Color.Lerp(Color.white, buttonColor, t);
|
||||
}
|
||||
}
|
||||
}
|
||||
18
Assets/External/Feel/MMFeedbacks/Editor/Sequencing/MMSequencerEditor.cs.meta
vendored
Normal file
18
Assets/External/Feel/MMFeedbacks/Editor/Sequencing/MMSequencerEditor.cs.meta
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6f57413f575191641b987d9d04e61e3a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 183370
|
||||
packageName: Feel
|
||||
packageVersion: 5.9.1
|
||||
assetPath: Assets/Feel/MMFeedbacks/Editor/Sequencing/MMSequencerEditor.cs
|
||||
uploadId: 830868
|
||||
8
Assets/External/Feel/MMFeedbacks/Editor/Sequencing/Resources.meta
vendored
Normal file
8
Assets/External/Feel/MMFeedbacks/Editor/Sequencing/Resources.meta
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 45d354ba7398508478aa7bd1ea7fd93d
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/External/Feel/MMFeedbacks/Editor/Sequencing/Resources/SequencerButtonBackground.png
vendored
Normal file
BIN
Assets/External/Feel/MMFeedbacks/Editor/Sequencing/Resources/SequencerButtonBackground.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 958 B |
146
Assets/External/Feel/MMFeedbacks/Editor/Sequencing/Resources/SequencerButtonBackground.png.meta
vendored
Normal file
146
Assets/External/Feel/MMFeedbacks/Editor/Sequencing/Resources/SequencerButtonBackground.png.meta
vendored
Normal file
@@ -0,0 +1,146 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e802b29e86b4ef74abe728250ecaf37c
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 10
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 0
|
||||
aniso: -1
|
||||
mipBias: -100
|
||||
wrapU: 1
|
||||
wrapV: 1
|
||||
wrapW: -1
|
||||
nPOTScale: 0
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 1
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 2, y: 2, z: 2, w: 2}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 1
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 8
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 3
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: iPhone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Android
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: WebGL
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID: 5e97eb03825dee720800000000000000
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
spritePackingTag:
|
||||
pSDRemoveMatte: 0
|
||||
pSDShowRemoveMatteOption: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 183370
|
||||
packageName: Feel
|
||||
packageVersion: 5.9.1
|
||||
assetPath: Assets/Feel/MMFeedbacks/Editor/Sequencing/Resources/SequencerButtonBackground.png
|
||||
uploadId: 830868
|
||||
BIN
Assets/External/Feel/MMFeedbacks/Editor/Sequencing/Resources/SequencerDotBackground.png
vendored
Normal file
BIN
Assets/External/Feel/MMFeedbacks/Editor/Sequencing/Resources/SequencerDotBackground.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 935 B |
146
Assets/External/Feel/MMFeedbacks/Editor/Sequencing/Resources/SequencerDotBackground.png.meta
vendored
Normal file
146
Assets/External/Feel/MMFeedbacks/Editor/Sequencing/Resources/SequencerDotBackground.png.meta
vendored
Normal file
@@ -0,0 +1,146 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 82c9d5c8726c57249b51c39e76eee072
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 10
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 0
|
||||
aniso: -1
|
||||
mipBias: -100
|
||||
wrapU: 1
|
||||
wrapV: 1
|
||||
wrapW: -1
|
||||
nPOTScale: 0
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 1
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 1
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 8
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 3
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: iPhone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Android
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: WebGL
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID: 5e97eb03825dee720800000000000000
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
spritePackingTag:
|
||||
pSDRemoveMatte: 0
|
||||
pSDShowRemoveMatteOption: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 183370
|
||||
packageName: Feel
|
||||
packageVersion: 5.9.1
|
||||
assetPath: Assets/Feel/MMFeedbacks/Editor/Sequencing/Resources/SequencerDotBackground.png
|
||||
uploadId: 830868
|
||||
Reference in New Issue
Block a user