From 2955f202a7ab7e24bc6b635a0b24051c3549011d Mon Sep 17 00:00:00 2001 From: max Date: Fri, 6 Dec 2019 11:25:38 +0100 Subject: [PATCH] Insta Trig Fixed --- .../VisualEffectGraph/VFX Graph Plane.unity | 7 ++- .../PdConnection/MidiTransitionController.cs | 46 +++++++++---------- 2 files changed, 26 insertions(+), 27 deletions(-) diff --git a/UnityProject/Assets/Scenes/Examples/VisualEffectGraph/VFX Graph Plane.unity b/UnityProject/Assets/Scenes/Examples/VisualEffectGraph/VFX Graph Plane.unity index 6423745..b64e858 100644 --- a/UnityProject/Assets/Scenes/Examples/VisualEffectGraph/VFX Graph Plane.unity +++ b/UnityProject/Assets/Scenes/Examples/VisualEffectGraph/VFX Graph Plane.unity @@ -195,7 +195,6 @@ MonoBehaviour: oneBarLoopButton: 86 fourBarLoopButton: 94 playableDirector: {fileID: 65620552} - lastSelectedScene: 0 currentSelectedScene: 0 nextSelectedScene: 0 channel: 3 @@ -1242,9 +1241,9 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 41f237c64f02a2241a30c5c0b5c087e6, type: 3} m_Name: m_EditorClassIdentifier: - logAll: 1 - logFiltered: 0 - filterStatusByte: 128 + logAll: 0 + logFiltered: 1 + filterStatusByte: 178 --- !u!1 &859452785 GameObject: m_ObjectHideFlags: 0 diff --git a/UnityProject/Assets/Scripts/PdConnection/MidiTransitionController.cs b/UnityProject/Assets/Scripts/PdConnection/MidiTransitionController.cs index aa3e570..7928702 100644 --- a/UnityProject/Assets/Scripts/PdConnection/MidiTransitionController.cs +++ b/UnityProject/Assets/Scripts/PdConnection/MidiTransitionController.cs @@ -13,17 +13,16 @@ namespace cylvester private int oneBarLoop = 96; private int fourBarLoop = 384; - private int instaTrig = 2; - private int nextSelectedSceneOutput = 18; - private int lastSelectedSceneOutput = 17; + private const int cmd_instaTrig = 2; + private const int cmd_nextSelectedScene = 18; + private const int cmd_currentSelectedScene = 17; private bool instaChangeActive; private int currentTick; private float transitionLength = 16; //sets the duration in Seconds, how long a transition has to be in "TimeLine" to be played back correctly when CYLVESTER is hooked up correctly private float restTimeS = 1f; //init transTime is 1 Second - [SerializeField] private int lastSelectedScene = 0; - [SerializeField] private int currentSelectedScene = 0; + [SerializeField] private int currentSelectedScene; [SerializeField] private int nextSelectedScene; [SerializeField, Range(1, 16)] private int channel = 1; @@ -41,13 +40,29 @@ namespace cylvester if (mes.Status - 176 == channel - 1) //Which Channel { - if (mes.Data1 == nextSelectedSceneOutput) + if (mes.Data1 == cmd_nextSelectedScene) { nextSelectedScene = mes.Data2; //Get next Schene Update } - if (mes.Data1 == lastSelectedSceneOutput) - lastSelectedScene = mes.Data2; //Get current selected Scene + if (mes.Data1 == cmd_instaTrig) + { + instaChangeActive = true; + } + + if (mes.Data1 == cmd_currentSelectedScene) + { + currentSelectedScene = mes.Data2; //Get current selected Scene + + if (instaChangeActive) + { + stateManager.SelectedState = currentSelectedScene; + playableDirector.playableGraph.GetRootPlayable(0).SetSpeed(10); + // Debug.Log("Instatrig " + currentSelectedScene); + // Debug.Log("Last selected Scene new " + lastSelectedScene); + instaChangeActive = false; + } + } if (mes.Data1 == oneBarLoopButton) //Button fourBarLoop { @@ -63,21 +78,6 @@ namespace cylvester stateManager.SelectedState = nextSelectedScene; } - if (mes.Data1 == instaTrig) - { - instaChangeActive = true; - - if (instaChangeActive && (currentSelectedScene != lastSelectedScene)) - { - currentSelectedScene = lastSelectedScene; - stateManager.SelectedState = lastSelectedScene; - playableDirector.playableGraph.GetRootPlayable(0).SetSpeed(10); - Debug.Log("Instatrig " + currentSelectedScene); - Debug.Log("Last selected Scene new " + lastSelectedScene); - instaChangeActive = false; - } - - } } }