unity update 协程_unity3d中协程和update进行比较

同一个计时的代码,

using UnityEngine;

using System.Collections;

public class CountSeconds : MonoBehaviour

{

int seconds = 0;

float timer = 0;

// Use this for initialization

void Start()

{

}

// Update is called once per frame

void Update()

{

timer += Time.deltaTime;

if (timer >= 1)

{

seconds++;

Debug.Log(seconds + "has passed ");

timer = 0;

}

}

}

using UnityEngine;

using System.Collections;

public class CountSeconds : MonoBehaviour

{

// Use this for initialization

void Start()

{

StartCoroutine("CountSecondsCrountine");

}

// Update is called once per frame

void U

你可能感兴趣的:(unity,update,协程)