• 카테고리

    질문 & 답변
  • 세부 분야

    게임 프로그래밍

  • 해결 여부

    해결됨

@Managers 생성 질문드립니다.

23.03.22 22:56 작성 23.03.22 22:57 수정 조회수 305

0

디버깅을 통해 @Managers가 생성되는 곳이 BaseScene에 Init이라는 것을 파악했지만, Init과 Managers.Resource.Instantiate 호출로 연관 없는 @Managers까지 생성되는 이유를 모르겠습니다.

BaseScene.cs

protected virtual void Init()

{

Object obj = GameObject.FindObjectOfType(typeof(EventSystem));

if (obj == null)

Managers.Resource.Instantiate("UI/EventSystem").name = "@EventSystem";

}

ResourceManager.cs

public GameObject Instantiate(string path, Transform parent = null)

{

GameObject original = Load<GameObject>($"Prefabs/{path}");

if (original == null)

{

Debug.Log($"Failed to load prefab : {path}");

return null;

}

if (original.GetComponent<Poolable>() != null)

return Managers.Pool.Pop(original, parent).gameObject;

GameObject go = Object.Instantiate(original, parent);

go.name = original.name;

return go;

}

답변 1

답변을 작성해보세요.

0

Managers.Resource 코드를 보면 Init(); return _resourceManager; 이런 식으로 되어 있을거에요.
@Managers가 없으면 생성하는 코드가 Init쪽에 들어가 있습니다.