- Home /
Showing Time With GUI.Label
Hello everyone, I have 2 scripts in different levels i want to show the time when level changed that's my script ;
using UnityEngine;
using System.Collections;
public class Timer : MonoBehaviour {
private float TimeScore = 0;
void Update () {
TimeScore += 1 * Time.deltaTime;
Debug.Log(TimeScore);
if (Application.loadedLevelName == "Level1end") {
PlayerPrefs.SetFloat("Timer",TimeScore);
}
}
}
And this is the other level script ;
using UnityEngine;
using System.Collections;
public class Level1End : MonoBehaviour {
public GUIStyle style;
void OnGUI()
{
{
GUI.Label (new Rect (50, 60, 500, 500), "Time : " + PlayerPrefs.GetFloat("Timer") , style );
}
{
}
}
}
I don't know what's wrong with my script Timer always 0.
Thanks.
Comment
Does it debug the right TimeScore from the top script, and if so does the value change in regedit?
Your answer
Follow this Question
Related Questions
Change GUI.Label text while it's active? 1 Answer
Time.deltaTime? 6 Answers
How to fast forward time (or just skip it) properly? 2 Answers