From c2b607572f04eeed62ff25886b65d26269ab7271 Mon Sep 17 00:00:00 2001 From: Abraham Date: Tue, 16 Apr 2024 09:36:59 -0400 Subject: [PATCH] reset variables and changed scene reloader to use string --- Assets/GolfControls/BallHitController.cs | 2 ++ Assets/GolfControls/StrokeCounter.cs | 6 ++++++ Assets/Scenes/TestControls.unity | 1 + Assets/Scripts/SceneReloader.cs | 5 ++++- 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Assets/GolfControls/BallHitController.cs b/Assets/GolfControls/BallHitController.cs index fd2ced61..885b901f 100644 --- a/Assets/GolfControls/BallHitController.cs +++ b/Assets/GolfControls/BallHitController.cs @@ -21,6 +21,8 @@ namespace GolfControls private void Start() { body = gameObject.GetComponent(); + inHoleVariable.SetValue(false); + isMovingVariable.SetValue(false); } private void OnEnable() diff --git a/Assets/GolfControls/StrokeCounter.cs b/Assets/GolfControls/StrokeCounter.cs index 94334f05..487ee337 100644 --- a/Assets/GolfControls/StrokeCounter.cs +++ b/Assets/GolfControls/StrokeCounter.cs @@ -10,6 +10,12 @@ namespace GolfControls public IntVariable StrokeVariable; public VoidEvent HitEvent; + + private void Start() + { + StrokeVariable.SetValue(0); + } + private void OnEnable() { HitEvent.Register(OnHit); diff --git a/Assets/Scenes/TestControls.unity b/Assets/Scenes/TestControls.unity index a58ce453..b91edc21 100644 --- a/Assets/Scenes/TestControls.unity +++ b/Assets/Scenes/TestControls.unity @@ -1834,6 +1834,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 8c6bc963a512bff438769c9188ce8e3a, type: 3} m_Name: m_EditorClassIdentifier: + startingSceneName: TestControls --- !u!4 &1028760416 Transform: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/SceneReloader.cs b/Assets/Scripts/SceneReloader.cs index b58234ee..9434468d 100644 --- a/Assets/Scripts/SceneReloader.cs +++ b/Assets/Scripts/SceneReloader.cs @@ -5,8 +5,11 @@ using UnityEngine.SceneManagement; public class SceneReloader : MonoBehaviour { + + public string startingSceneName; + public void Reload() { - SceneManager.LoadScene(0); + SceneManager.LoadScene(startingSceneName); } }