본문 바로가기

코딩/UNITY

유니티 GameObject 관련 설정시 component에서 오브젝트가 빠지는 현상

유니티를 사용하다가 분명 시작전엔 정상적으로 Component에 들어있는 GameObject가 실행만하면 빠져서

 

"MissingComponentException: There is no 'GameObject' attached to the "Gamemanager" game object, but a script is trying to access it."

 

오류가 뜨는 경우가 있다. 그럴떄는

object = GetComponent<GameObject>();

같이 컴포넌트를 할당해주는 코드를 빼면 된다.