สร้างโลกของคุณเอง
การเขียนสคริปต์
คอร์รูทีน
1นาที
โคโรทีนคือส่วนประกอบของโปรแกรมที่ทำงานแบบมัลติทาสก์ที่ไม่ถูกขัดจังหวะ ซึ่งทำงานโดยการหยุดการทำงานและจากนั้นดำเนินการต่อจากจุดที่หยุดไว้ มันถูกใช้เพื่อดำเนินการฟีเจอร์เช่นการทำงานแบบอะซิงโครนัส ข้อยกเว้น ลูปเหตุการณ์ ตัววนซ้ำ รายการไม่สิ้นสุด และท่อ คลิกที่นี่เพื่อเรียนรู้เพิ่มเติมเกี่ยวกับโคโรทีนของ unity 📘 โคโรทีน https //docs unity3d com/kr/current/manual/coroutines html https //docs unity3d com/kr/current/manual/coroutines html การนำโคโรทีนของ unity ไปใช้ใน zepetoscript มีดังนี้ 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); } } } ตรวจสอบหน้าจอผลลัพธ์ของโค้ดทดสอบด้านล่าง