From ee65ecfda5fd7b76b240fadd4b2a5e317c6e19b6 Mon Sep 17 00:00:00 2001
From: Michael Guerrero <insominx@yahoo.com>
Date: Wed, 5 Jun 2019 15:09:54 -0700
Subject: [PATCH] Fixed scriptable object values not resetting themselves
 leading to unwanted execution.

---
 Scriptable Variables/Events/GameEvent.cs | 16 +++++++++++++---
 package.json                             |  2 +-
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/Scriptable Variables/Events/GameEvent.cs b/Scriptable Variables/Events/GameEvent.cs
index 49cd47b..4ea1536 100644
--- a/Scriptable Variables/Events/GameEvent.cs	
+++ b/Scriptable Variables/Events/GameEvent.cs	
@@ -8,7 +8,12 @@ namespace Shared.ScriptableVariables {
     public delegate void GameEventRaised();
     public event GameEventRaised OnRaised;
 
-    int lastEventRaisedFrame = 0;
+    int lastEventRaisedFrame = -1;
+    
+    //---------------------------------------------------------------------------
+    void OnDisable() {
+      lastEventRaisedFrame = -1;
+    }
 
     //---------------------------------------------------------------------------
     [ContextMenu("Raise")]
@@ -32,14 +37,18 @@ namespace Shared.ScriptableVariables {
     public delegate void GameEventRaised(T value);
     public event GameEventRaised OnRaised;
 
-    int lastEventRaisedFrame = 0;
+    int lastEventRaisedFrame = -1;
+
+    //---------------------------------------------------------------------------
+    void OnDisable() {
+      lastEventRaisedFrame = -1;
+    }
 
     //---------------------------------------------------------------------------
     public void Raise(T value) {
       if (OnRaised != null) {
         OnRaised(value);
       }
-      
       lastEventRaisedFrame = Time.frameCount;
     }
 
@@ -51,3 +60,4 @@ namespace Shared.ScriptableVariables {
     }
   }
 }
+
diff --git a/package.json b/package.json
index 892816e..8b0923f 100644
--- a/package.json
+++ b/package.json
@@ -2,7 +2,7 @@
 	"name": "com.futuretech.shared",
 	"displayName": "FutureTech Shared",
 	"description": "Contains shared items such as the Scriptable Variables.",
-	"version": "0.1.10",
+	"version": "0.1.11",
 	"unity": "2018.3",
 	"license": "MIT",
 	"repository": {
-- 
GitLab