- Home /
Multiple stopwatch
Hi, I'm a beginner. I tried to make two stopwatches, but Unity crashes whenever it reaches to the second stopwatch statement. I'm assuming that I'm using stopwatch incorrectly. Can anyone fix it? Also, some of the libraries below are for other parts of the code, but I want to clarify which library I use for stopwatch. The part of the code is as follow:
//
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Diagnostics;
using System;
//
public int timer1 = 2;
public int timer2 = 10;
//
Stopwatch s = new Stopwatch();
Stopwatch t = new Stopwatch();
//
s.Start();
s.Stop();
//
t.Start();
t.Stop();
Comment
When do you get the error message, at runtime when compiling?
What is the error?
What operating system are you using?
Are you using Visual Studio, or something else to generate this code?
What version of Unity are you using?