인프런 커뮤니티 질문&답변

김진호님의 프로필 이미지

작성한 질문수

[Rookiss 켠김에 출시까지] 유니티 방치형 키우기 게임 (M1 + T2)

UI

UI_Base 질문

24.02.14 01:29 작성

·

209

·

수정됨

0

protected void Bind<T>(Type type) where T : UnityEngine.Object

{

string[] names = Enum.GetNames(type);

UnityEngine.Object[] objects = new UnityEngine.Object[names.Length];

_objects.Add(typeof(T), objects);

for (int i = 0; i < names.Length; i++)

{

if (typeof(T) == typeof(GameObject))

objects[i] = Util.FindChild(gameObject, names[i], true);

else

objects[i] = Util.FindChild<T>(gameObject, names[i], true);

if (objects[i] == null)

Debug.Log($"Failed to bind({names[i]})");

}

}

 

 

 

에서 순서가

 

 

for (int i = 0; i < names.Length; i++)

{

if (typeof(T) == typeof(GameObject))

objects[i] = Util.FindChild(gameObject, names[i], true);

else

objects[i] = Util.FindChild<T>(gameObject, names[i], true);

if (objects[i] == null)

Debug.Log($"Failed to bind({names[i]})");

}

로 object에 value를 findchild로 먼저 다 넣어주고

그 뒤에 objects.add로 dic형태 _objects에다 채워주어야 하지않나요?

 

상관없나요?

답변 1

0

Rookiss님의 프로필 이미지
Rookiss
지식공유자

2024. 02. 14. 01:30

참조값이라 상관없습니다.