From cb1cfdc82d0a892667ed681d66ffa29347840f25 Mon Sep 17 00:00:00 2001 From: Acid Bubbles Date: Sat, 26 Nov 2022 21:03:53 -0500 Subject: [PATCH] Restore "legacy" time mode for older versions for backward compatibility (please update the time mode in early access 6.1 releases!) --- VamTimeline.AtomAnimation.cslist | 1 - VamTimeline.csproj | 1 - meta.json | 1 - .../Animations/AtomAnimation.cs | 28 +++++++++++++++++-- src/AtomAnimations/Animations/TimeModes.cs | 3 +- .../Animations/TimeTypeValues.cs | 12 -------- src/UI/Screens/OptionsScreen.cs | 17 ++++++++--- tests/VamTimeline.Tests.cslist | 1 - 8 files changed, 41 insertions(+), 23 deletions(-) delete mode 100644 src/AtomAnimations/Animations/TimeTypeValues.cs diff --git a/VamTimeline.AtomAnimation.cslist b/VamTimeline.AtomAnimation.cslist index ab1669d1..f3d38d86 100644 --- a/VamTimeline.AtomAnimation.cslist +++ b/VamTimeline.AtomAnimation.cslist @@ -25,7 +25,6 @@ src\AtomAnimations\Animations\AtomPose.cs src\AtomAnimations\Animations\IAtomAnimationClip.cs src\AtomAnimations\Animations\IAtomAnimationTargetsList.cs src\AtomAnimations\Animations\TimeModes.cs -src\AtomAnimations\Animations\TimeTypeValues.cs src\AtomAnimations\Animations\UnitySpecific.cs src\AtomAnimations\Animations\VamOverlaysFadeManager.cs src\AtomAnimations\BezierCurves\Smoothing\BezierAnimationCurveSmoothingBase.cs diff --git a/VamTimeline.csproj b/VamTimeline.csproj index 6edaec7a..c6473f36 100644 --- a/VamTimeline.csproj +++ b/VamTimeline.csproj @@ -100,7 +100,6 @@ - diff --git a/meta.json b/meta.json index b607dd4c..d876b8e2 100644 --- a/meta.json +++ b/meta.json @@ -36,7 +36,6 @@ "Custom\\Scripts\\AcidBubbles\\Timeline\\src\\AtomAnimations\\Animations\\IAtomAnimationClip.cs", "Custom\\Scripts\\AcidBubbles\\Timeline\\src\\AtomAnimations\\Animations\\IAtomAnimationTargetsList.cs", "Custom\\Scripts\\AcidBubbles\\Timeline\\src\\AtomAnimations\\Animations\\TimeModes.cs", - "Custom\\Scripts\\AcidBubbles\\Timeline\\src\\AtomAnimations\\Animations\\TimeTypeValues.cs", "Custom\\Scripts\\AcidBubbles\\Timeline\\src\\AtomAnimations\\Animations\\UnitySpecific.cs", "Custom\\Scripts\\AcidBubbles\\Timeline\\src\\AtomAnimations\\Animations\\VamOverlaysFadeManager.cs", "Custom\\Scripts\\AcidBubbles\\Timeline\\src\\AtomAnimations\\BezierCurves\\Smoothing\\BezierAnimationCurveSmoothingBase.cs", diff --git a/src/AtomAnimations/Animations/AtomAnimation.cs b/src/AtomAnimations/Animations/AtomAnimation.cs index 4a064ef2..9273ee60 100644 --- a/src/AtomAnimations/Animations/AtomAnimation.cs +++ b/src/AtomAnimations/Animations/AtomAnimation.cs @@ -39,7 +39,19 @@ private void OnTargetsListChanged() public void Update() { - var deltaTime = timeMode == TimeModes.RealTime ? (Time.time - _lastUpdateTime) : Time.deltaTime; + float deltaTime; + switch (timeMode) + { + case TimeModes.RealTime: + deltaTime = Time.time - _lastUpdateTime; + break; + case TimeModes.RealTimeLegacy: + deltaTime = Time.unscaledDeltaTime * Time.timeScale; + break; + default: + deltaTime = Time.deltaTime; + break; + } _lastUpdateTime = Time.time; SyncTriggers(true); @@ -60,7 +72,19 @@ public void Update() public void FixedUpdate() { - var deltaTime = timeMode == TimeModes.RealTime ? (Time.time - _lastFixedUpdateTime) : Time.deltaTime; + float deltaTime; + switch (timeMode) + { + case TimeModes.RealTime: + deltaTime = Time.time - _lastFixedUpdateTime; + break; + case TimeModes.RealTimeLegacy: + deltaTime = Time.unscaledDeltaTime * Time.timeScale; + break; + default: + deltaTime = Time.deltaTime; + break; + } _lastFixedUpdateTime = Time.time; diff --git a/src/AtomAnimations/Animations/TimeModes.cs b/src/AtomAnimations/Animations/TimeModes.cs index a4dc56e0..dc10e42c 100644 --- a/src/AtomAnimations/Animations/TimeModes.cs +++ b/src/AtomAnimations/Animations/TimeModes.cs @@ -3,6 +3,7 @@ public static class TimeModes { public const int UnityTime = 0; - public const int RealTime = 1; + public const int RealTimeLegacy = 1; + public const int RealTime = 2; } } diff --git a/src/AtomAnimations/Animations/TimeTypeValues.cs b/src/AtomAnimations/Animations/TimeTypeValues.cs deleted file mode 100644 index 0bda4834..00000000 --- a/src/AtomAnimations/Animations/TimeTypeValues.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace VamTimeline -{ - public static class TimeTypeValues - { - public const int GameTime = 0; - public const int RealTime = 1; - /* - public const int SceneAnimation = 2; - public const int AudioTrack = 3; - */ - } -} diff --git a/src/UI/Screens/OptionsScreen.cs b/src/UI/Screens/OptionsScreen.cs index 8553ea5b..ea02cf30 100644 --- a/src/UI/Screens/OptionsScreen.cs +++ b/src/UI/Screens/OptionsScreen.cs @@ -59,14 +59,23 @@ private void InitLockedUI() private void InitUseRealTimeUI() { - var timeTypeJSON = new JSONStorableStringChooser("Time mode", new List {TimeTypeValues.GameTime.ToString(), TimeTypeValues.RealTime.ToString()}, TimeTypeValues.GameTime.ToString(), "Time mode"); - timeTypeJSON.displayChoices = new List + var timeModes = new List {TimeModes.UnityTime.ToString(), TimeModes.RealTime.ToString()}; + var timeModeDisplay = new List { "Game time (slows with low fps)", "Real time (better for audio sync)" }; - timeTypeJSON.valNoCallback = animation.timeMode.ToString(); - timeTypeJSON.setCallbackFunction = val => animation.timeMode = int.Parse(val); + if (animation.timeMode == TimeModes.RealTimeLegacy) + { + timeModes.Add(TimeModes.RealTimeLegacy.ToString()); + timeModeDisplay.Add("Real time (legacy, only use for old scenes)"); + } + var timeTypeJSON = new JSONStorableStringChooser("Time mode", timeModes, TimeModes.UnityTime.ToString(), "Time mode") + { + displayChoices = timeModeDisplay, + valNoCallback = animation.timeMode.ToString(), + setCallbackFunction = val => animation.timeMode = int.Parse(val) + }; prefabFactory.CreatePopup(timeTypeJSON, true, true); } diff --git a/tests/VamTimeline.Tests.cslist b/tests/VamTimeline.Tests.cslist index a4f88ab2..f9da6437 100644 --- a/tests/VamTimeline.Tests.cslist +++ b/tests/VamTimeline.Tests.cslist @@ -25,7 +25,6 @@ ..\src\AtomAnimations\Animations\IAtomAnimationClip.cs ..\src\AtomAnimations\Animations\IAtomAnimationTargetsList.cs ..\src\AtomAnimations\Animations\TimeModes.cs -..\src\AtomAnimations\Animations\TimeTypeValues.cs ..\src\AtomAnimations\Animations\UnitySpecific.cs ..\src\AtomAnimations\Animations\VamOverlaysFadeManager.cs ..\src\AtomAnimations\BezierCurves\Smoothing\BezierAnimationCurveSmoothingBase.cs