From 75615259f03036737225f455264705d49fa2f9d4 Mon Sep 17 00:00:00 2001 From: Ava Gaiety Wroten Date: Tue, 16 Jun 2020 20:22:07 -0500 Subject: [PATCH] Level complete allows loading next scene --- Assets/Scripts/ChargeCounter.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Assets/Scripts/ChargeCounter.cs b/Assets/Scripts/ChargeCounter.cs index 3f40b7e..aefb885 100644 --- a/Assets/Scripts/ChargeCounter.cs +++ b/Assets/Scripts/ChargeCounter.cs @@ -1,5 +1,6 @@ using System.Collections; using System.Collections.Generic; +using UnityEngine.SceneManagement; using UnityEngine; public class ChargeCounter : MonoBehaviour @@ -7,12 +8,19 @@ public class ChargeCounter : MonoBehaviour bool levelComplete = false; GameObject[] chargePoints; List chargedPoints = new List(); + Scene currentScene; void Start() { + currentScene = SceneManager.GetActiveScene(); if (chargePoints == null) chargePoints = GameObject.FindGameObjectsWithTag("Charge Point"); } + void Update() + { + if (levelComplete && Input.anyKey) LoadNextLevel(); + } + public void AddChargedPoint(GameObject chargePoint) { chargedPoints.Add(chargePoint); @@ -41,4 +49,9 @@ public class ChargeCounter : MonoBehaviour transform.GetChild(0).gameObject.SetActive(true); levelComplete = true; } + + void LoadNextLevel() + { + SceneManager.LoadScene(currentScene.buildIndex + 1); + } }