I am new to unity and i just want to make sure my code is working right(no hidden bug or anything like that)
public class pingping : MonoBehaviour {
Ping ping;
List pingList;
void Start ()
{
pingList = new List ();
StartCoroutine (PingUpdate());
}
IEnumerator PingUpdate()
{
ping = new Ping ("216.52.241.254");
while (!ping.isDone)
{
yield return null;
}
pingList.Add (ping.time);
Debug.Log (ping.time);
yield return new WaitForSeconds (1f);
StartCoroutine (PingUpdate ());
}
}
Code is just supposed to collect pings every 1-2 sec.
↧