Skip to content

Commit

Permalink
Fixed mesh smoothing button timer incrementing too quickly when multi…
Browse files Browse the repository at this point in the history
…ple characters in scene
  • Loading branch information
thojmr committed Jan 27, 2022
1 parent da4a221 commit 4e73c7a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions PregnancyPlus/PregnancyPlus.Core/GUI/PPGui.ButtonTimer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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;

Expand Down Expand Up @@ -63,6 +67,7 @@ public static void StopTextCountIncrement()

secondsCount = -1;
timePassed = 0f;
lastFrameCount = 0;

UpdateTextComponentText();
}
Expand Down
3 changes: 0 additions & 3 deletions PregnancyPlus/PregnancyPlus.Core/PPCharaController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions PregnancyPlus/PregnancyPlus.Core/PPPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 4e73c7a

Please sign in to comment.