ํ์ ์ฐฝ ๋จ๋ฉด ๊ฑฐ๊ธฐ ํ ์คํธ๊ฐ ํ์ด๋์ธ, ํ์ด๋์์ ๋๋ ์ฝ๋ ์ง๋์ค์
ํ์ ๋จ๋ ํจ์์์ ์๋์ ๊ฐ์ ์ฝ๋ฃจํด ์ฝ๋ ๋ง๋ฆ
ย ย ย private IEnumerator PopUpEnd()
ย ย ย {
ย ย ย ย ย ย ย float fadeCount = 0f;
ย ย ย ย ย ย ย popUpText.color = new Color(255, 255, 255, fadeCount);
ย ย ย ย ย ย ย while (fadeCount < 1.0f)
ย ย ย ย ย ย ย {
ย ย ย ย ย ย ย ย ย ย ย fadeCount += 0.02f;
ย ย ย ย ย ย ย ย ย ย ย yield return new WaitForSeconds(0.01f);
ย ย ย ย ย ย ย ย ย ย ย popUpText.color = new Color(255, 255, 255, fadeCount);
ย ย ย ย ย ย ย }
ย ย ย ย ย ย ย yield return new WaitForSeconds(2.0f);
ย ย ย ย ย ย ย while (fadeCount > 0f)
ย ย ย ย ย ย ย {
ย ย ย ย ย ย ย ย ย ย ย fadeCount -= 0.01f;
ย ย ย ย ย ย ย ย ย ย ย yield return new WaitForSeconds(0.01f);
ย ย ย ย ย ย ย ย ย ย ย popUpText.color = new Color(255, 255, 255, fadeCount);
ย ย ย ย ย ย ย }
ย ย ย ย ย ย ย popUpText.text = "";
ย ย ย ย ย ย ย popUpPanel.SetActive(false);
ย ย ย }
ํ ์คํธ ์ํ๊ฐ 0์ผ๋ก ๋ง๋ค๊ณ ,
์ํ๊ฐ 1์ด ๋ ๋๊น์ง 0.01์ด๋ง๋ค 0.02์ฉ ์ํ๊ฐ ์ค๋ฅด๊ณ ,
2์ด ๊ธฐ๋ค๋ฆฐ ํ,
์ํ๊ฐ 0์ด๋ ๋๊น์ง 0.01์ด๋ง๋ค 0.01์ฉ ์ํ๊ฐ ๋จ์ด์ง
์ฌ๊ธฐ์ ๊ถ๊ธํ๊ฑด ๋ด๊ฐ ์ํ๋ ๋งํผ
yield return new WaitForSeconds ์ด๊ฑธ ์์ฑํด๋ ๋ฌธ์ ๊ฐ ์๋์ง?
60ํ๋ ์์ด๋ฉด ํ๋ ์๋น ๋์ถฉ 0.016์ด์ผ. 0.01์ด๋ฉด 2ํ๋ ์์ด์ผ. ๊ทธ๋ฅ yield return null ์ด๋?
new ๊ฑฑ์ ๋๋ฉด public staticclass Caching { public static WaitforSeconds wait10ms = new WaitForSecond(0.01f) ; } ๋ง๋ค๊ณ yield return Caching.wait10ms; ์ฒ๋ผ์จ
์, ์ ์ 0.01์ด๋ฉด ํํ๋ ์๋ ์๋ผ.
null ํ๋ฉด ์ด๋ป๊ฒ ๋๋๊ฑด๋ฐ? ์ ๋ถ๋ถ์ ๊ทธ๋ฅ ๊ฐ์ข๋ค ๋ณด๋ฉด ์ ๋ฐ ์์ผ๋ก ๋์ด์๊ณ ๋ณ๋ง ์๊ธธ๋ ์ผ๋๋ฐ
null ์ ํ ํ๋ ์ ๊ธฐ๋ค๋ฆฐ๋จ ๋ป
์ํ ๊ทธ๋ผ null ์จ๋ ๋๋๊ฑฐ ์๋? ํ๋ ์ ๊ธฐ์ค์ผ๋ก ๊ธฐ๋ค๋ฆฌ๋๊ฒ ์ข์๊ฑฐ๊ฐ์๋ฐ
new๊ฐ ๊ฑฑ์ ๋๋๋๊ฒ ์ด๋ค ์๋ฏธ์ธ์ง ์ ๋ชจ๋ฅด๊ฒ ์ด
๋ฌธ์ ์์ ์ฝ๋ฃจํด์ 1ํ๋ ์์ ํ๋ฒ ๋์๊ฐ๋๊น waitForSecond ์ฐ๋ฉด ์ข ๋๊ธฐ๋ฏ์ด ๋ฐ๋๊ฒ ์ง ใ ใ
๊ฐ์ฌ๊ฐ์ฌ