Capture time and display on a new panel
Posted: Mon Oct 07, 2019 9:37 am
Hey there! Hope you have a nice day ahead!
I have a question here. Is there any way to display the time consumed on the panel?
There is a counter I set for the countdown in Quest Machine. I have tried using the script to display, but I do not know what's wrong with my script.
Here is my code:
Other than using the script, do you have other suggestion which is easier for me as I'm not good at coding?
Thanks for your time and sorry if troubling you.
I have a question here. Is there any way to display the time consumed on the panel?
There is a counter I set for the countdown in Quest Machine. I have tried using the script to display, but I do not know what's wrong with my script.
Here is my code:
Code: Select all
public Text timerText;
private float startTime;
public QuestState newState;
void Start(){
startTime = Time.time;
}
void CaptureTime (){
string minutes;
if (newState == QuestState.Active){
Debug.Log("1");
float t = Time.time - startTime;
minutes = ((int)t / 60).ToString("00");
string seconds = (t % 60).ToString("00");
timerText.text = minutes + ":" + seconds;
}
}
void Update(){
CaptureTime();
}
Thanks for your time and sorry if troubling you.