Answers for "unity stopwatch timer"

C#
0

unity stopwatch timer

using System.Collections; 
using System.Collections.Generic; 
using UnityEngine;
using UnityEngine.UI;

public class Timerexample : MonoBehaviour
{

float val;
bool srt,stp,rst;
public Text disvar;

void Start()
{
val=0;
srt=false;
stp=false;
rst=false;
}

void Update() 

{ 

if(srt)     

{         
val += Time.deltaTime;    
} 

double b = System.Math.Round (val, 2);     

disvar.text = b.ToString ();    
}
public void stopbutton()
{
srt=false;
}
public void resetbutton()
{
srt=false;
val=0;
}
public void startbutton()
{
start=true;
}
}
Posted by: Guest on June-15-2021

C# Answers by Framework

Browse Popular Code Answers by Language