Hi community,
In my model, I have a scene with “Fire fighting” name.
I have set a timer of 120 secs like a countdown. Once after the timer is decremented to 0 then it reloads the scene According to my timer script. After reloading the scene. We are unable to navigate the scene.
I have attached my Timer script. Please check.
How to navigate in scene after reloading the “Fire fighting” scene?
Thanks in advance
using System.Collections; using
> System.Collections.Generic; using
> UnityEngine; using UnityEngine.UI;
> using System; using
> UnityEngine.SceneManagement;
>
> public class GameTimer : MonoBehaviour
> {
> int countDownStartValue = 120;
> public Text timerUI;
> // Start is called before the first frame update
> void Start()
> {
> countDownTimer();
>
> }
>
> // Update is called once per frame
> void countDownTimer()
> {
> if(countDownStartValue > 0)
> {
> TimeSpan spanTime = TimeSpan.FromSeconds(countDownStartValue);
> timerUI.text = "Timer : "+ spanTime.Minutes +" : "+
> spanTime.Seconds;
> countDownStartValue--;
> Invoke("countDownTimer", 1.0f);
> }
> else
> {
> timerUI.text = "GameOver!";
>
> SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
> }
> } }