---
title: Coroutine
slug: world-sdk-guide-kr/coroutine
docTags: 
createdAt: 2024-09-02T08:34:13.135Z
---

코루틴은 실행을 일시 중지한 다음 중단된 지점에서 계속 진행하는 비선점 멀티태스킹 프로그램 구성 요소입니다. 주로 비동기 작업, 예외, 이벤트 루프, 반복자, 무한 목록 및 파이프와 같은 기능을 실행하는 데 사용됩니다.

여기를 클릭하여 Unity의 코루틴에 대해 더 알아보세요.

:::hint{type="info"}
**📘 코루틴**

[https://docs.unity3d.com/kr/current/Manual/Coroutines.html](https://docs.unity3d.com/kr/current/Manual/Coroutines.html)
:::



Unity 코루틴의 ZEPETO 스크립트 구현은 다음과 같습니다.

```javascript
import { ZepetoScriptBehaviour } from 'ZEPETO.Script';
import { WaitForSeconds } from 'UnityEngine';

export default class Coroutine extends ZepetoScriptBehaviour {
    
    private current: number;
    
    Start() {
        this.current = 0;
        console.log(`start routine`);
        this.StartCoroutine(this.DoRoutine());
    }

    *DoRoutine() {
        while(true) {
            yield null;
            console.log(`[${this.current++}] Wait to next routine..`);
            yield new WaitForSeconds(1);
        }
    }
}
```

아래의 테스트 코드 출력 화면을 확인하세요.

![](https://api.archbee.com/api/optimize/fCt3n1oCa8rgNJ8fw9I2N-yagc5tebV4H6DBE7pWuAA-20240904-102426.png)

