โช์ ๋ํฐ์์ sleep()์ด ์๋ค
๋ฐฉ๋ฒ : time.deltatime , destroy , invoke , coroutine
1.Time.deltaTime์ด์ฉ
waitingTime ๊ฒฝ๊ณผ ํ ํน์ ์์ ์ ๋ฐ๋ณต ์คํํจ
2. Destory()
๊ฐ์ฒด๊ฐ ์์ฑ๋ ์ดํ ํน์ ์๊ฐ์ด ๊ฒฝ๊ณผํ ๋ค์ ์ ๊ฑฐํ๊ธฐ
3.Invoke()
ํน์ ์์ ์ดํ ํจ์ ํธ์ถํ๊ธฐ
4.Coroutineํจ์ ์ด์ฉํ๊ธฐ
์๊ฐ์ด ์ค๋ ๊ฑธ๋ฆฌ๋ ์์ ์ ๋น๋๊ธฐ(asynchronous)๋ก ์ฒ๋ฆฌ์ ์ฌ์ฉ
โช ํ ์ปดํฌ๋ํธ ๋ด์์ Update ํจ์์ ๋ฐ๋ก ์ผ์์ ์ผ๋ก ๋์๊ฐ๋ ์๋ธ ๋์์ ๊ตฌํํ ๋ ์ฌ์ฉ
โช ์ด๋ค ๋ค๋ฅธ ์์ ์ด ์ฒ๋ฆฌ๋๋ ๊ฒ์ ๊ธฐ๋ค๋ฆฌ๋ ๊ธฐ๋ฅ์ ๊ตฌํํ๋๋ฐ ์ฌ์ฉ
โช Coroutine์ ๋ณ๋์ ์ฐ๋ ๋์ ๊ฐ์ด ๋์ํจ (์ค์ ๋ณ๋ ์ฐ๋ ๋๋ ์๋)
โช Coroutine ํจ์ ์์ฑ ๋ฐฉ๋ฒ – ๋ฆฌํด ํ์ ์ IEnumerator๋ผ์ผ ํจ
– ํจ์ ๋ด์ yield return ๊ตฌ๋ฌธ์ด ์์ด์ผ ํจ – yield return null;
โช๋ค์ Update()๊ฐ ์คํ๋ ๋ ๊น์ง ๊ธฐ๋ค๋ฆผ
– yield return new WaitForSeconds(float time);
โชtime์ด ๋์ ๊ธฐ๋ค๋ฆผ
– yield return new WaitForEndOfFrame();
โช๋ ํฐ๋ง์ด ๋๋๊ณ ํ์ฌ ํ๋ ์์ด ์ข ๋ฃ๋ ๋๊น์ง ๊ธฐ๋ค๋ฆผ
โช Coroutine ํธ์ถ ๋ฐฉ๋ฒ
– MonoBehaviour.StartCoroutine – public Coroutine StartCoroutine(IEnumerator routine)
'๐ชดEtc > ๐ญ C# and Unity' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
ํ์ ๋ํ์ค(Tower Defence) (0) | 2022.11.09 |
---|---|
Airplane ๊ฒ์ (0) | 2022.11.05 |
๋ก์ผ ๋ ๋ฆฌ๊ธฐ (0) | 2022.11.05 |
์ฒซ unity ๊ฐ๋จํ ๊ฒ์ ๋ง๋ค๊ธฐ (0) | 2022.11.05 |