using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CoroutineTest2 : MonoBehaviour
{
float curruntTime;
void Start()
{
curruntTime = 0f;
StartCoroutine("Waiting");
StartCoroutine("MouseClick");
}
IEnumerator Waiting()
{
while (true)
{
if (curruntTime >= 2f)
{
Debug.LogFormat("대기 중 : {0}초", Mathf.RoundToInt(curruntTime)); // curruntTime 반올림
curruntTime = 0f;
}
yield return null;
curruntTime += Time.deltaTime;
}
}
IEnumerator MouseClick()
{
while (true)
{
if(Input.GetMouseButtonDown(0))
{
StopCoroutine("Waiting");
Debug.Log("완료");
}
yield return null;
}
}
}
반응형
'산대특 > 게임 플랫폼 응용 프로그래밍' 카테고리의 다른 글
A* 알고리즘 구현해보기 (1) - 이동 불가 노드와 이동 가능 노드 구별하기 (0) | 2024.03.03 |
---|---|
Larva 클릭 및 드래그로 TargetPoint 지정하기 (0) | 2024.03.01 |
코루틴 안에서 코루틴 실행하기 (0) | 2024.02.29 |
탱크 시즈모드 Splash 공격 구현하기 (0) | 2024.02.29 |
탱크 공격 과 폭발 이펙트 + 적 삭제 구현하기 (0) | 2024.02.29 |