์ฐธ์กฐํ๋๋ฐ ํน์ ์ค๋ฅ๊ฐ์์๊น๋ด c++์์๋ ํฌ์ธํฐ๋ฅผ ์ฌ์ฉํ๋ ์ป๋ ๋ฐฉ๋ฒ์ธ๋ฐ
public Gameobject []units//์๋ํฐ์์ ํ ๋น๋์ด์์
GameObject currentUnit;
์ด๋คํจ์์์์
currentUnit = units[1];
currentUnit.์คํฌ๋ฆฝํธ์์ ์๊ธฐ์ค๋ธ์ ํธ ์ด๋ฆ์ ๋ก๊น
currentUnit = units[2];
currentUnit.์์ ์ ๊ฐ์
์ด๋ฐ์์ผ๋ก ์ฌ์ฉํด๋ ๋ ๊น?? ํด๋ณด๋๊น ์ด์ํ๊ฒ ์คํฌ๋ฆฝํธ์์ ๊ฒ์์ค๋ธ์ ํธ ์ด๋ฆ์ ํธ์ถํ๋๋ฐ ์ฒซ๋ฒ์งธ ์ค๋ธ์ ํธ์ ๋๋ฒ์งธ๊ฐ ๋ถ๋ช ๋ค๋ฅธ๋ฐ ๊ฐ์์ด๋ฆ์ ํธ์ถํด์.. ํฌ์ธํฐ ์ฐ๋๊ฒ์ฒ๋ผ ์ด๋ ๊ฒ์ฌ์ฉํด๋๋๋๊ฑฐ์ผ??
public Gameobject []units//์๋ํฐ์์ ํ ๋น๋์ด์์
GameObject currentUnit;
์ด๋คํจ์์์์
currentUnit = units[1];
currentUnit.์คํฌ๋ฆฝํธ์์ ์๊ธฐ์ค๋ธ์ ํธ ์ด๋ฆ์ ๋ก๊น
currentUnit = units[2];
currentUnit.์์ ์ ๊ฐ์
์ด๋ฐ์์ผ๋ก ์ฌ์ฉํด๋ ๋ ๊น?? ํด๋ณด๋๊น ์ด์ํ๊ฒ ์คํฌ๋ฆฝํธ์์ ๊ฒ์์ค๋ธ์ ํธ ์ด๋ฆ์ ํธ์ถํ๋๋ฐ ์ฒซ๋ฒ์งธ ์ค๋ธ์ ํธ์ ๋๋ฒ์งธ๊ฐ ๋ถ๋ช ๋ค๋ฅธ๋ฐ ๊ฐ์์ด๋ฆ์ ํธ์ถํด์.. ํฌ์ธํฐ ์ฐ๋๊ฒ์ฒ๋ผ ์ด๋ ๊ฒ์ฌ์ฉํด๋๋๋๊ฑฐ์ผ??
๋จ
[SerializeField] GameObject[] units;GameObject currentUnit;void Start(){ currentUnit = units[0]; Debug.Log(currentUnit); currentUnit = units[1]; Debug.Log(currentUnit);}
๊ฒฐ๊ณผ Unit1 Unit2
ํด๋์ค ๋ฐ๋ ๋ณ์๋ ์ ๋ถ๋ค ์ฐธ์กฐ์ผ.. ํฌ์ธํฐ๋ผ๊ณ ์๊ฐํ๋ฉด๋จ
๊ฐ์ฌ์ฉ