Quantcast
Channel: Questions in topic: "error"
Viewing all articles
Browse latest Browse all 7934

How do add scenes on the Countdown Timer

$
0
0
I need to add a scene on one of the line on my Countdown Timer . The scene for player just in case the player wins or loses : I also have an error : error CS0103: The name `GetInitialTime' does not exist in the current context Here is my score script : 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); } } Here is my Countdown Timer script ;using UnityEngine; using System.Collections; using UnityEngine.UI; public class MyClock : MonoBehaviour { public int Minutes = 0; public int Seconds = 0; private Text m_text; private float m_leftTime; void Start () { m_text = GetComponent(); m_leftTime = GetInitialTime(); StartCoroutine(StartTimer()); } IEnumerator StartTimer() { bool done = false; float decrementTime = 1.0f; // default yield time (one second) float timeLeft = m_leftTime; while (timeLeft > 0) { if (m_text != null) { m_text.text = string.Format("{0:D2}:{1:D2}", (timeLeft / 60), (timeLeft % 60)); } yield return new WaitForSeconds(decrementTime); timeLeft -= decrementTime; } yield return new WaitForSeconds(0.01f); // added this just incase } }

Viewing all articles
Browse latest Browse all 7934

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>