简体   繁体   中英

Unity/C# Stopwatch If Time Has Elapsed statement (timer > 0)

Searched the interwebs for a while and got something that pointed me in the right direction so I could get the answer. Thought I'd share it for somebody in the future:

How to write an if statement in C# for a Stopwatch to check if time as elapsed

public Stopwatch timer = new Stopwatch();

if(timer.Elapsed.TotalSeconds == 0) {
    // if timer hasn't started
}

or

if(timer.Elapsed.TotalSeconds > 0) {
    // if timer has started
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM