How would add an scene on the Countdown Timer
I need to know where I should add an scene in my Countdown Timer script . The purpose for having a scene for the player . If the player wins or lose . I also have and Score System script. Here are my scripts :
using UnityEngine; using UnityEngine.UI;
public class MyClock : MonoBehaviour { public int Minutes = 0; public int Seconds = 0;
private Text m_text;
private float m_leftTime;
private void Awake()
{
m_text = GetComponent<Text>();
m_leftTime = GetInitialTime();
}
private void Update()
{
if (m_leftTime > 0f)
{
// Update countdown clock
m_leftTime -= Time.deltaTime;
Minutes = GetLeftMinutes();
Seconds = GetLeftSeconds();
// Show current clock
if (m_leftTime > 0f)
{
m_text.text = "Time : " + Minutes + ":" + Seconds.ToString("00");
}
else
{
// The countdown clock has finished
m_text.text = "Time : 0:00";
}
}
}
private float GetInitialTime()
{
return Minutes * 60f + Seconds;
}
private int GetLeftMinutes()
{
return Mathf.FloorToInt(m_leftTime / 60f);
}
private int GetLeftSeconds()
{
return Mathf.FloorToInt(m_leftTime % 60f);
}
}
using UnityEngine; using System.Collections; using UnityEngine.UI;
public class ScoreManager : MonoBehaviour { public int currentScore = 0; public Text text; ScoreManager scoreManager; void Start () {
text = GetComponent (); currentScore = 0; UpdateScore(0); scoreManager = gameObject.GetComponent(); // this may not be exactly how you get a reference to ScoreManager
}
void UpdateScore(int score)
{
currentScore += score;
if (text != null)
{
text.text = "Score :" + currentScore;
}
scoreManager.UpdateScore(100);
}
}
Answer by Ryanless · May 05, 2016 at 10:56 PM
Could it be that you worded that wrong. Because a scene is a SCENE like it has its own camera and light and gameObjects and whatnot....
Though if I understand it right, add the animation or Ui-elemts on line 23 when the clock run out of time. Since i gess you cant lose or win before times run out.
Your answer
Follow this Question
Related Questions
How do I switch scenes with countdown timer and Score at the same time 0 Answers
Passing Score from Game Scene to Game Over Scene usiing dontDestroyOnLoad C# 1 Answer
How do I stop a scene from switching from switch before the Countdown timer reaches zero 2 Answers
how to get remaining time in a count down timer as a score? 1 Answer
How do add scenes on the Countdown Timer 0 Answers