diff --git a/UnityProject/Assets/Animations/Cube.controller b/UnityProject/Assets/Animations/Cube.controller index 8fb6f85..6803438 100644 --- a/UnityProject/Assets/Animations/Cube.controller +++ b/UnityProject/Assets/Animations/Cube.controller @@ -15,7 +15,7 @@ AnimatorState: m_StateMachineBehaviours: [] m_Position: {x: 50, y: 50, z: 0} m_IKOnFeet: 0 - m_WriteDefaultValues: 1 + m_WriteDefaultValues: 0 m_Mirror: 0 m_SpeedParameterActive: 0 m_MirrorParameterActive: 0 @@ -36,11 +36,11 @@ AnimatorController: m_Name: Cube serializedVersion: 5 m_AnimatorParameters: - - m_Name: AnimTrigger - m_Type: 9 + - m_Name: Moving + m_Type: 4 m_DefaultFloat: 0 m_DefaultInt: 0 - m_DefaultBool: 1 + m_DefaultBool: 0 m_Controller: {fileID: 0} m_AnimatorLayers: - serializedVersion: 5 @@ -90,9 +90,9 @@ AnimatorStateTransition: m_PrefabAsset: {fileID: 0} m_Name: m_Conditions: - - m_ConditionMode: 1 - m_ConditionEvent: AnimTrigger - m_EventTreshold: 0 + - m_ConditionMode: 6 + m_ConditionEvent: Moving + m_EventTreshold: 1 m_DstStateMachine: {fileID: 0} m_DstState: {fileID: -985118024630667659} m_Solo: 0 @@ -101,9 +101,9 @@ AnimatorStateTransition: serializedVersion: 3 m_TransitionDuration: 0.25 m_TransitionOffset: 0 - m_ExitTime: 0.75 - m_HasExitTime: 1 - m_HasFixedDuration: 1 + m_ExitTime: 1 + m_HasExitTime: 0 + m_HasFixedDuration: 0 m_InterruptionSource: 0 m_OrderedInterruption: 1 m_CanTransitionToSelf: 1 @@ -114,18 +114,21 @@ AnimatorStateTransition: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_Name: - m_Conditions: [] + m_Conditions: + - m_ConditionMode: 2 + m_ConditionEvent: Moving + m_EventTreshold: 0 m_DstStateMachine: {fileID: 0} m_DstState: {fileID: 1370166835903048213} m_Solo: 0 m_Mute: 0 m_IsExit: 0 serializedVersion: 3 - m_TransitionDuration: 0.5383635 + m_TransitionDuration: 0 m_TransitionOffset: 0 - m_ExitTime: 0.40248495 - m_HasExitTime: 1 - m_HasFixedDuration: 1 + m_ExitTime: 1 + m_HasExitTime: 0 + m_HasFixedDuration: 0 m_InterruptionSource: 0 m_OrderedInterruption: 1 m_CanTransitionToSelf: 1 @@ -140,10 +143,10 @@ AnimatorStateMachine: m_ChildStates: - serializedVersion: 1 m_State: {fileID: 1370166835903048213} - m_Position: {x: 300, y: 60, z: 0} + m_Position: {x: 340, y: 60, z: 0} - serializedVersion: 1 m_State: {fileID: -985118024630667659} - m_Position: {x: 620, y: -60, z: 0} + m_Position: {x: 340, y: -30, z: 0} m_ChildStateMachines: [] m_AnyStateTransitions: [] m_EntryTransitions: [] @@ -151,6 +154,6 @@ AnimatorStateMachine: m_StateMachineBehaviours: [] m_AnyStatePosition: {x: 50, y: 20, z: 0} m_EntryPosition: {x: 50, y: 120, z: 0} - m_ExitPosition: {x: 800, y: 120, z: 0} + m_ExitPosition: {x: 520, y: 140, z: 0} m_ParentStateMachinePosition: {x: 800, y: 20, z: 0} m_DefaultState: {fileID: 1370166835903048213} diff --git a/UnityProject/Assets/Animations/OrangeBoxAnimation1.anim b/UnityProject/Assets/Animations/OrangeBoxAnimation1.anim index 93ffe20..f2de9b5 100644 --- a/UnityProject/Assets/Animations/OrangeBoxAnimation1.anim +++ b/UnityProject/Assets/Animations/OrangeBoxAnimation1.anim @@ -13,33 +13,33 @@ AnimationClip: m_UseHighQualityCurve: 1 m_RotationCurves: [] m_CompressedRotationCurves: [] - m_EulerCurves: + m_EulerCurves: [] + m_PositionCurves: - curve: serializedVersion: 2 m_Curve: - serializedVersion: 3 time: 0 - value: {x: 0, y: 0, z: 0} + value: {x: -5, y: -5, z: 0} inSlope: {x: 0, y: 0, z: 0} - outSlope: {x: 0, y: 0, z: 0} + outSlope: {x: 10, y: 0, z: 0} tangentMode: 0 weightedMode: 0 inWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334} outWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334} - serializedVersion: 3 time: 1 - value: {x: 360, y: 360, z: 360} - inSlope: {x: 0, y: 0, z: 0} + value: {x: 5, y: -5, z: 0} + inSlope: {x: 10, y: 0, z: 0} outSlope: {x: 0, y: 0, z: 0} tangentMode: 0 weightedMode: 0 - inWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334} + inWeight: {x: 0.050967038, y: 0.33333334, z: 0.33333334} outWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334} m_PreInfinity: 2 m_PostInfinity: 2 m_RotationOrder: 4 path: - m_PositionCurves: [] m_ScaleCurves: [] m_FloatCurves: [] m_PPtrCurves: [] @@ -52,10 +52,10 @@ AnimationClip: genericBindings: - serializedVersion: 2 path: 0 - attribute: 4 + attribute: 1 script: {fileID: 0} typeID: 4 - customType: 4 + customType: 0 isPPtrCurve: 0 pptrCurveMapping: [] m_AnimationClipSettings: @@ -68,7 +68,7 @@ AnimationClip: m_Level: 0 m_CycleOffset: 0 m_HasAdditiveReferencePose: 0 - m_LoopTime: 1 + m_LoopTime: 0 m_LoopBlend: 0 m_LoopBlendOrientation: 0 m_LoopBlendPositionY: 0 @@ -84,7 +84,35 @@ AnimationClip: m_Curve: - serializedVersion: 3 time: 0 - value: 0 + value: -5 + inSlope: 0 + outSlope: 10 + tangentMode: 65 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + - serializedVersion: 3 + time: 1 + value: 5 + inSlope: 10 + outSlope: 0 + tangentMode: 5 + weightedMode: 0 + inWeight: 0.050967038 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + attribute: m_LocalPosition.x + path: + classID: 4 + script: {fileID: 0} + - curve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: -5 inSlope: 0 outSlope: 0 tangentMode: 136 @@ -93,7 +121,7 @@ AnimationClip: outWeight: 0.33333334 - serializedVersion: 3 time: 1 - value: 360 + value: -5 inSlope: 0 outSlope: 0 tangentMode: 136 @@ -103,7 +131,7 @@ AnimationClip: m_PreInfinity: 2 m_PostInfinity: 2 m_RotationOrder: 4 - attribute: localEulerAnglesRaw.x + attribute: m_LocalPosition.y path: classID: 4 script: {fileID: 0} @@ -121,25 +149,6 @@ AnimationClip: outWeight: 0.33333334 - serializedVersion: 3 time: 1 - value: 360 - inSlope: 0 - outSlope: 0 - tangentMode: 136 - weightedMode: 0 - inWeight: 0.33333334 - outWeight: 0.33333334 - m_PreInfinity: 2 - m_PostInfinity: 2 - m_RotationOrder: 4 - attribute: localEulerAnglesRaw.y - path: - classID: 4 - script: {fileID: 0} - - curve: - serializedVersion: 2 - m_Curve: - - serializedVersion: 3 - time: 0 value: 0 inSlope: 0 outSlope: 0 @@ -147,53 +156,14 @@ AnimationClip: weightedMode: 0 inWeight: 0.33333334 outWeight: 0.33333334 - - serializedVersion: 3 - time: 1 - value: 360 - inSlope: 0 - outSlope: 0 - tangentMode: 136 - weightedMode: 0 - inWeight: 0.33333334 - outWeight: 0.33333334 m_PreInfinity: 2 m_PostInfinity: 2 m_RotationOrder: 4 - attribute: localEulerAnglesRaw.z - path: - classID: 4 - script: {fileID: 0} - m_EulerEditorCurves: - - curve: - serializedVersion: 2 - m_Curve: [] - m_PreInfinity: 2 - m_PostInfinity: 2 - m_RotationOrder: 4 - attribute: m_LocalEulerAngles.x - path: - classID: 4 - script: {fileID: 0} - - curve: - serializedVersion: 2 - m_Curve: [] - m_PreInfinity: 2 - m_PostInfinity: 2 - m_RotationOrder: 4 - attribute: m_LocalEulerAngles.y - path: - classID: 4 - script: {fileID: 0} - - curve: - serializedVersion: 2 - m_Curve: [] - m_PreInfinity: 2 - m_PostInfinity: 2 - m_RotationOrder: 4 - attribute: m_LocalEulerAngles.z + attribute: m_LocalPosition.z path: classID: 4 script: {fileID: 0} + m_EulerEditorCurves: [] m_HasGenericRootTransform: 1 m_HasMotionFloatCurves: 0 m_Events: [] diff --git a/UnityProject/Assets/Scenes/Examples/MIDI/MIDI.unity b/UnityProject/Assets/Scenes/Examples/MIDI/MIDI.unity index 6b45e93..6b71668 100644 --- a/UnityProject/Assets/Scenes/Examples/MIDI/MIDI.unity +++ b/UnityProject/Assets/Scenes/Examples/MIDI/MIDI.unity @@ -244,7 +244,18 @@ MonoBehaviour: csvFileName: qlist onStateChanged: m_PersistentCalls: - m_Calls: [] + m_Calls: + - m_Target: {fileID: 1843145352} + m_MethodName: OnStateChanged + m_Mode: 0 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 sceneSelection: 0 --- !u!4 &337815216 Transform: @@ -795,7 +806,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: f5f9defef7af2514590dadc0a6cddbac, type: 3} m_Name: m_EditorClassIdentifier: - loopLengthInBeat: 4 + loopLengthInBeat: 1 loopStarted: m_PersistentCalls: m_Calls: diff --git a/UnityProject/Assets/Scenes/Examples/MIDI/script/OrangeCube.cs b/UnityProject/Assets/Scenes/Examples/MIDI/script/OrangeCube.cs index e7efe7a..70a3e70 100644 --- a/UnityProject/Assets/Scenes/Examples/MIDI/script/OrangeCube.cs +++ b/UnityProject/Assets/Scenes/Examples/MIDI/script/OrangeCube.cs @@ -5,13 +5,21 @@ namespace cylvester public class OrangeCube : MonoBehaviour { [SerializeField] private Animator anim; - private static readonly int AnimTrigger = Animator.StringToHash("AnimTrigger"); - + private float speed_ = 1.0f; + private static readonly int Moving = Animator.StringToHash("Moving"); + private bool trigger_; + public void OnTriggerReceived() { - anim.SetTrigger(AnimTrigger); + anim.speed = speed_; + + anim.SetBool(Moving, false); + anim.SetBool(Moving, true); + } + + public void OnStateChanged(IStateReader currentState) + { + speed_ = currentState.CurrentState.Speed; } - - } } diff --git a/UnityProject/Assets/Scripts/StateManagement/StateManager.cs b/UnityProject/Assets/Scripts/StateManagement/StateManager.cs index 4816074..fa81f46 100644 --- a/UnityProject/Assets/Scripts/StateManagement/StateManager.cs +++ b/UnityProject/Assets/Scripts/StateManagement/StateManager.cs @@ -4,31 +4,33 @@ using UnityEngine.Events; namespace cylvester { - [Serializable] - public class UnityStateEvent : UnityEvent - {} + + public interface IStateReader + { + State CurrentState { get; } + } - public interface IStateManager + public interface IStateManager : IStateReader { int SelectedState { set; } - State[] States { get; } - State CurrentState { get; } State? PreviousState { get; } State? NextState { get; } - - void OnMidiReceived(MidiMessage message); } public struct State { public string Title; public string Note; - public int BPM; + public int Bpm; - private float Speed => BPM / 60f; // 60 BPM as speed 1f + public float Speed => Bpm / 60f; // 60 BPM as speed 1f } + [Serializable] + public class UnityStateEvent : UnityEvent + {} + public class StateManager : MonoBehaviour, IStateManager { private enum Operation @@ -57,11 +59,11 @@ namespace cylvester try { - States[i].BPM = int.Parse(columns[1]); + States[i].Bpm = int.Parse(columns[1]); } catch (FormatException) { - States[i].BPM = 60; // gracefully fail + States[i].Bpm = 60; // gracefully fail } States[i].Note = columns[2];