์ฝ๋ฃจํด ๋ก๋ฉ()//๊ฒ์๋งค๋์ ํด๋์ค(๋ค๋ฅธ ์คํฌ๋ฆฝํธํ์ผ)
{// ์ฌ๊ธฐ ์๋ ์ฝ๋ฃจํด ๋ชจ๋ ๊ฐ์ ๋ค๋ฅธ ํด๋์ค, ๋ค๋ฅธ ์คํฌ๋ฆฝํธ ๋ด์ ์ ํ ์ฝ๋ฃจํด๋ค์ด์ผ
yield return ์คํํธ์ฝ๋ฃจํด( ํ์ผ๋งต ์ธํ () );
yield return ์คํํธ์ฝ๋ฃจํด( ๋จธ์๊ธฐ ์ธํ () ); yield return ์คํํธ์ฝ๋ฃจํด( ๊ฑฐ์๊ธฐ ์ธํ
() );
}
์ฝ๋ฃจํด ํ์ผ๋งต ์ธํ ()
{
//===============================
//๊ธฐํ ๋ณ์ ์ ์ธ๋ค์ ๋๊ธฐ๊ณ ..
//===============================
for (int i = -1; i
{
for (int j = -1; j
{
GameObject toInstantiateHolder = m_Tiles[Random.Range(0, m_Tiles.Length)];
GameObject instantiate;
if (i == -1 || i == m_nX || j == -1 || j == m_nY)
{
toInstantiateHolder = m_Wall[0];
instantiate = Instantiate(toInstantiateHolder, new Vector3(i, j, 2.0f), Quaternion.identity) as GameObject;
}
else
{
if(toInstantiateHolder == null)
{
Debug.Log((i * m_nX + j) + "๋ฒ์งธ toInstantiateHolder๊ฐ ๋์ด๋ค.");
}
instantiate = Instantiate(toInstantiateHolder, new Vector3(i, j, 2.0f), Quaternion.identity) as GameObject;
instantiate.gameObject.GetComponent().GetMyNum((i * m_nX) + j);
Vector3 v3 = instantiate.gameObject.transform.position;
v3.z = instantiate.gameObject.transform.GetChild(3).transform.position.z;
instantiate.gameObject.transform.GetChild(3).transform.position = v3;
int nRandom = Random.Range(m_nMinDanger, m_nMaxDanger);
instantiate.gameObject.GetComponent().Set_DangerPoint(nRandom);
nRandom = Random.Range(m_nMinDanger, m_nMaxDanger);
instantiate.gameObject.GetComponent().Set_ZombieDensity(nRandom);
m_liTiles.Add(instantiate.gameObject.GetComponent());
}
instantiate.transform.parent = m_BoardHolder;
GameManager.m_Instance.AddLoadingCount();
yield return new WaitForEndOfFrame();
}
}
}
์ด๋ ๊ฒ ํด๋จ๋๋ฐ
์๋ํฐ ๋ด๋ถ์์๋ ์คํ์ด ๋๊ฒ ์๋ผ.
๊ทผ๋ฐ exe๋ apk๋ก ๋ฝ์์ ์ฐ๋ฉด
๊ธ์ ๋ฐฐ๊ฒฝ์ ํด๋์ ๋ณ์๊ฐ ๋์ด ๋ค์ด๊ฐ๋ฒ๋ ค์
์ฝ๋ฃจํด์ด ์ฃฝ์ด๋ฒ๋ ค
(์๋ํฐ๋ก ์คํํด์)๋๋ฒ๊น ๋ ํด๋ดค๋๋ฐ ๋ฐ์ดํฐ๋ ์ ๋ค์ด๊ฐ ์๋๋ผ๊ณ ..
์ด๊ฑฐ ํน์ ์ ๋ํฐ ์์ง ๋ฒ๊ทธ์ผ??
๋ฒ์ ์ 17.1.0f3 ์ด์ผ.
//--------------------------------------------------
ํฌ๋ฌธ ๋ค์ด๊ฐ๊ธฐ ์ ์ ๊ฒ์ฌํด๋ณด๋๊น m_Tiles[0] ๊ฐ null์ด๋ค...
์ฌ ์์๋ ๋ ํด๋น ์ค๋ธ์ ํธ๊ฐ ๊ฐ๊ณ ์์ด์ผ ํ๋๋ฐ...
์ด๋ ๊ฒ ๋ฃ์ด๋๊ณ ์ฌ ์์๋๋ฉด
๋ก๋ฉ ์์ ์ ์ ์์ฑ๋๋ ์ค๋ธ์ ํธ์ ๋ฃ์ด๋จ๊ฑฐ๋ ..
m_Tiles ๊ฐ ์ด๊ธฐํ ๋๋ ์์ ์ด๋ ๋ก๋ฉ ์ฝ๋ฃจํด์ด ์คํ๋๋ ์์ ์ด ์ค์ํ ๋ฏ. ์๋ํฐ์์๋ ๋ชจ๋ ๊ฒ์ ์ค๋ธ์ ํธ๋ค์ด ์ด๋ฏธ ๋ก๋๋์ด ์์ง๋ง ์ค์ ์คํ์์๋ ๋ก๋ฉ ์ฝ๋ฃจํด์ ์คํํ๋ ์์ ์ m_Tile ์ ๋ค์ด๊ฐ๋ ๊ฒ์ ์ค๋ธ์ ํธ๋ค์ด ์์ง ๋ก๋๊ฐ ๋์ง ์์์ ๊ฐ๋ฅ์ฑ์ด ์์.
m_Tiles๋ GameBoard๋ผ๋ ์ค๋ธ์ ํธ์ ์ปดํฌ๋ํธ๋ก ํฌํจ๋์ด ์๋ GameBoard ํด๋์ค์ public ํ์ผ๋ก ๋์ด ์์ด์ ์๋ํฐ๋ด์์ ์ปดํฌ๋ํธ๋ก ๋ฐ๋ก ์ถ๊ฐํด๋จ์ด m_Tiles๋ Tile ์ข ๋ฅ๋ณ๋ก ์ ์ฅ๋ Prefabs๋ค์ ๋ณด๊ดํ๋ ๋ณ์๊ณ ..ํด๋น ์ฌ ์์๋ ๋ ์ ๋ถ ๊ฐ๊ณ ์๋ ์ํ๋ก ์์ํ๋๋ฐ...์ด๊ธฐํ ํ๋๊ฑฐ ๋ค์ํ๋ฒ ๋ด์ผ๊ฒ ๋ค..๊ณ ๋ง์
For๋ฌธ ๋ค์ด๊ฐ๊ธฐ ์ ์ m_Tiles ๋ฐ์ดํฐ ๊ฒ์ฌํ๋๊น ์ด์ ์๋ค...ํ.........................
๊ณ์ ํ์ธํด๋ด์ผ๊ฒ ๋ค ์ํผ ใณใณ
๋ฏธ์ ๋ค์ ํ์ธํด๋ณด๋ m_Tiles๊ฐ ํฌ๋ฌธ ๋ค์ด๊ฐ๊ธฐ๋ ์ ์ ์ด์์ด ์์๋ค..
m_liTiles.Add(instantiate.gameObject.GetComponent()); m_Tiles๊ฐ ์ปค์ง๊ณ ์์ด์. GetComponent๊ฐ Extension ํจ์์ธ๊ฐ์? Null์ ๋ฃ์ด์ฃผ๋๊ฒ ์๋๊น ์์ฌ๋์
m_liTiles.Add(instantiate.gameObject.GetComponent<Tile>()); ์ธ๋ฐ ๋ณต๋ถํ ๋ Tile์ด ๋น ์ก๋๋ณด๋ค...๋ฌธ์ ๋๋ ๋ณ์๋ toInstantiateHolder์ผ..
GetComponent๋ Unity์์ ์ง์ํด์ฃผ๋ ์ค๋ธ์ ํธ๊ฐ ๊ฐ๊ณ ์๋ ์ปดํฌ๋ํธ๋ฅผ ์ฐพ์์ฃผ๋ ํจ์
์ ํด๊ฒฐํ๊ฑฐ๊ฐ๋ค...๋ณด๋๊น ๋น ๋ฐ์ดํฐ ๊ฐ๊ณ ์ด์ ์ฌ์๋ ์์๋ค...์ ์ด๋ฐ ์ค์๋ฅผ...