using System.Collections;
using UnityEngine;
public class CoroutineTest : MonoBehaviour
{
float curruntTime = 0f;
void Start()
{
StartCoroutine("TimeWatch");
StartCoroutine("FirstCo");
}
IEnumerator FirstCo()
{
// 3초 동안 대기
yield return new WaitForSeconds(3);
// 정수로 표시 (반올림)
Debug.LogFormat("첫번째 코루틴 시작 : {0}초", Mathf.RoundToInt(curruntTime));
StartCoroutine("SecondCo");
}
IEnumerator SecondCo()
{
// 추가적으로 2초 동안 대기
yield return new WaitForSeconds(2);
// 정수로 표시 (반올림)
Debug.LogFormat("두번째 코루틴 시작 : {0}초", Mathf.RoundToInt(curruntTime));
}
IEnumerator TimeWatch()
{
while (true)
{
curruntTime += Time.deltaTime;
}
}
}
반응형
'산대특 > 게임 플랫폼 응용 프로그래밍' 카테고리의 다른 글
Larva 클릭 및 드래그로 TargetPoint 지정하기 (0) | 2024.03.01 |
---|---|
화면을 클릭할때까지 기다리다가 2초마다 "대기중" 이라고 출력하고, 화면을 클릭하면 "완료" 라고 출력하기 (0) | 2024.02.29 |
탱크 시즈모드 Splash 공격 구현하기 (0) | 2024.02.29 |
탱크 공격 과 폭발 이펙트 + 적 삭제 구현하기 (0) | 2024.02.29 |
탱크 이동과 모드 전환 구현하기 (0) | 2024.02.29 |