From 44aade812bc71bffac55a891c1c985eb4d86bf47 Mon Sep 17 00:00:00 2001 From: Christopher Date: Fri, 30 Sep 2016 12:03:30 +0100 Subject: [PATCH] Changed float comparisons to use Mathf.Approximately --- Assets/Fungus/Scripts/Commands/CallMethod.cs | 2 +- Assets/Fungus/Scripts/Commands/FadeUI.cs | 6 +++--- Assets/Fungus/Scripts/Commands/PlayUsfxrSound.cs | 2 +- Assets/Fungus/Scripts/Components/CameraManager.cs | 2 +- Assets/Fungus/Scripts/Components/MusicManager.cs | 2 +- Assets/Fungus/Scripts/Components/SayDialog.cs | 2 +- Assets/Fungus/Scripts/Components/SpriteFader.cs | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Assets/Fungus/Scripts/Commands/CallMethod.cs b/Assets/Fungus/Scripts/Commands/CallMethod.cs index df7dc2a5..d0d9e718 100644 --- a/Assets/Fungus/Scripts/Commands/CallMethod.cs +++ b/Assets/Fungus/Scripts/Commands/CallMethod.cs @@ -41,7 +41,7 @@ namespace Fungus.Commands return; } - if (delay == 0f) + if (Mathf.Approximately(delay, 0f)) { CallTheMethod(); } diff --git a/Assets/Fungus/Scripts/Commands/FadeUI.cs b/Assets/Fungus/Scripts/Commands/FadeUI.cs index e4978357..6927a91e 100644 --- a/Assets/Fungus/Scripts/Commands/FadeUI.cs +++ b/Assets/Fungus/Scripts/Commands/FadeUI.cs @@ -37,7 +37,7 @@ namespace Fungus.Commands { foreach (Image image in go.GetComponentsInChildren()) { - if (duration == 0f) + if (Mathf.Approximately(duration, 0f)) { switch (fadeMode) { @@ -67,7 +67,7 @@ namespace Fungus.Commands foreach (Text text in go.GetComponentsInChildren()) { - if (duration == 0f) + if (Mathf.Approximately(duration, 0f)) { switch (fadeMode) { @@ -97,7 +97,7 @@ namespace Fungus.Commands foreach (TextMesh textMesh in go.GetComponentsInChildren()) { - if (duration == 0f) + if (Mathf.Approximately(duration, 0f)) { switch (fadeMode) { diff --git a/Assets/Fungus/Scripts/Commands/PlayUsfxrSound.cs b/Assets/Fungus/Scripts/Commands/PlayUsfxrSound.cs index 53734c64..764370a2 100644 --- a/Assets/Fungus/Scripts/Commands/PlayUsfxrSound.cs +++ b/Assets/Fungus/Scripts/Commands/PlayUsfxrSound.cs @@ -56,7 +56,7 @@ using Fungus.Variables; { _synth.SetParentTransform(ParentTransform); _synth.Play(); - if (waitDuration == 0f) + if (Mathf.Approximately(waitDuration, 0f)) { Continue(); } diff --git a/Assets/Fungus/Scripts/Components/CameraManager.cs b/Assets/Fungus/Scripts/Components/CameraManager.cs index a8bb4751..93527250 100644 --- a/Assets/Fungus/Scripts/Components/CameraManager.cs +++ b/Assets/Fungus/Scripts/Components/CameraManager.cs @@ -428,7 +428,7 @@ namespace Fungus swipePanActive = false; - if (duration == 0f) + if (Mathf.Approximately(duration, 0f)) { // Move immediately camera.orthographicSize = targetSize; diff --git a/Assets/Fungus/Scripts/Components/MusicManager.cs b/Assets/Fungus/Scripts/Components/MusicManager.cs index 2337870b..214fad29 100644 --- a/Assets/Fungus/Scripts/Components/MusicManager.cs +++ b/Assets/Fungus/Scripts/Components/MusicManager.cs @@ -78,7 +78,7 @@ namespace Fungus { AudioSource audio = GetComponent(); - if (duration == 0f) + if (Mathf.Approximately(duration, 0f)) { audio.pitch = pitch; if (onComplete != null) diff --git a/Assets/Fungus/Scripts/Components/SayDialog.cs b/Assets/Fungus/Scripts/Components/SayDialog.cs index 8acf3704..1f015c92 100644 --- a/Assets/Fungus/Scripts/Components/SayDialog.cs +++ b/Assets/Fungus/Scripts/Components/SayDialog.cs @@ -144,7 +144,7 @@ namespace Fungus targetAlpha = 1f; fadeCoolDownTimer = 0.1f; } - else if (fadeWhenDone && fadeCoolDownTimer == 0f) + else if (fadeWhenDone && Mathf.Approximately(fadeCoolDownTimer, 0f)) { targetAlpha = 0f; } diff --git a/Assets/Fungus/Scripts/Components/SpriteFader.cs b/Assets/Fungus/Scripts/Components/SpriteFader.cs index 7d7eb119..f43fff83 100644 --- a/Assets/Fungus/Scripts/Components/SpriteFader.cs +++ b/Assets/Fungus/Scripts/Components/SpriteFader.cs @@ -96,7 +96,7 @@ namespace Fungus } // Early out if duration is zero - if (duration == 0f) + if (Mathf.Approximately(duration, 0f)) { spriteRenderer.color = targetColor; if (onComplete != null)