From 4e73c7aefcbbc0863e4d846bcdfa11b8f2ad80a0 Mon Sep 17 00:00:00 2001 From: thojm Date: Thu, 27 Jan 2022 16:19:53 -0500 Subject: [PATCH] Fixed mesh smoothing button timer incrementing too quickly when multiple characters in scene --- PregnancyPlus/PregnancyPlus.Core/GUI/PPGui.ButtonTimer.cs | 5 +++++ PregnancyPlus/PregnancyPlus.Core/PPCharaController.cs | 3 --- PregnancyPlus/PregnancyPlus.Core/PPPlugin.cs | 3 +++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/PregnancyPlus/PregnancyPlus.Core/GUI/PPGui.ButtonTimer.cs b/PregnancyPlus/PregnancyPlus.Core/GUI/PPGui.ButtonTimer.cs index bf6984e..4665476 100644 --- a/PregnancyPlus/PregnancyPlus.Core/GUI/PPGui.ButtonTimer.cs +++ b/PregnancyPlus/PregnancyPlus.Core/GUI/PPGui.ButtonTimer.cs @@ -14,6 +14,8 @@ public static partial class PregnancyPlusGui //Appends seonds count to blendshape smoothing text operation button. Starts incrementing timer when >= 0 internal static int secondsCount = -1; internal static float timePassed = 0f; + //OnGui can be called multiple times per frame, make sure the count is higher before triggering again + internal static float lastFrameCount = 0; //For updating UI text over time (place in MonoBehavior Update()) @@ -22,6 +24,8 @@ public static void Update() //When incrementing text count, add 1 every second if (secondsCount >= 0) { + if (Time.frameCount <= lastFrameCount) return; + lastFrameCount = Time.frameCount; //Keep track of the seconds passed timePassed += Time.deltaTime; @@ -63,6 +67,7 @@ public static void StopTextCountIncrement() secondsCount = -1; timePassed = 0f; + lastFrameCount = 0; UpdateTextComponentText(); } diff --git a/PregnancyPlus/PregnancyPlus.Core/PPCharaController.cs b/PregnancyPlus/PregnancyPlus.Core/PPCharaController.cs index 6ae030c..550ce23 100644 --- a/PregnancyPlus/PregnancyPlus.Core/PPCharaController.cs +++ b/PregnancyPlus/PregnancyPlus.Core/PPCharaController.cs @@ -185,9 +185,6 @@ protected override void OnReload(GameMode currentGameMode) protected override void Update() { - //Update GUI text - PregnancyPlusGui.Update(); - //Used to inflate/deflate in main game WatchForUserKeyPress(); //Used to incrementally inflate belly during HScene diff --git a/PregnancyPlus/PregnancyPlus.Core/PPPlugin.cs b/PregnancyPlus/PregnancyPlus.Core/PPPlugin.cs index a1aea92..f017c6a 100644 --- a/PregnancyPlus/PregnancyPlus.Core/PPPlugin.cs +++ b/PregnancyPlus/PregnancyPlus.Core/PPPlugin.cs @@ -90,6 +90,9 @@ internal void OnGUI() { if (!StudioAPI.InsideStudio) return; + //Update GUI text + PregnancyPlusGui.Update(); + //Need to trigger all children GUI that should be active. var handlers = CharacterApi.GetRegisteredBehaviour(GUID); if (handlers == null || handlers.Instances == null) return;