Created
August 31, 2018 09:50
-
-
Save todorok1/975c6bae760df2643e9041de781c3bfc to your computer and use it in GitHub Desktop.
コルーチンの使用例
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class CoroutineTest : MonoBehaviour { | |
void Start(){ | |
// コルーチンを開始 | |
StartCoroutine(DelayProcess(1.0f)); | |
Debug.Log("コルーチンを起動しました。"); | |
} | |
IEnumerator DelayProcess(float wait){ | |
float startTime = Time.time; | |
Debug.Log("開始時刻は : " + startTime); | |
// 指定秒数待つ | |
yield return new WaitForSeconds(wait); | |
// デバッグ文の表示 | |
float endTime = Time.time; | |
float diff = endTime - startTime; | |
Debug.Log("終了時刻は : " + endTime); | |
Debug.Log(diff + "秒待ってから処理されました。"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment