Version: 5.3 (switch to 5.4b)
언어English
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

WaitForSeconds

class in UnityEngine

/

Inherits from:YieldInstruction

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

닫기

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

닫기

취소

Switch to Manual

Description

주어진 시간(초)동안, co-routine의 수행을 중단합니다.

The actual time suspended is equal to the given time multiplied by Time.timeScale.
See WaitForSecondsRealtime if you wish to wait using unscaled time.
WaitForSeconds 는 co-routine안에서 yield 구문을 이용해야만 사용할 수 있습니다.

Note: There are some factors which can mean the actual amount of time waited does not precisely match the amount of time specified.

- WaitForSeconds starts waiting at the end of the current frame. So, if you start a WaitForSeconds with duration 't' in a very long frame (for example, one which has a long operation which blocks the main thread such as some synchronous loading), the coroutine will return 't' seconds after the end of the frame, not 't' seconds after it was called.

- WaitForSeconds will allow the coroutine to resume on the first frame after 't' seconds has passed, not exactly after 't' seconds has passed.

// Prints 0
print (Time.time);
// Waits 5 seconds
yield WaitForSeconds (5);
// Prints 5.0
print (Time.time);
using UnityEngine;
using System.Collections;

public class WaitForSecondsExample : MonoBehaviour { void Start() { StartCoroutine(Example()); } IEnumerator Example() { print(Time.time); yield return new WaitForSeconds(5); print(Time.time); } }

Constructors

WaitForSecondsCreates a yield instruction to wait for a given number of seconds using scaled time.

Inherited members