• 카테고리

    질문 & 답변
  • 세부 분야

    게임 프로그래밍

  • 해결 여부

    미해결

디스트로이 관련 2가지 질문입니다.

21.01.04 20:43 작성 조회수 163

0

tank가 아닌 prefer 로 선언했을 떄는 

Destroying assets is not permitted to avoid data loss.

If you really want to remove an asset use DestroyImmediate (theObject, true);

UnityEngine.Object:Destroy(Object, Single)

PrefabTest:Start() (at Assets/Script/Managers/PrefabTest.cs:15)

라는 메시지를 출력하는데 이 이유에 대해 알 수 있을까요? 

또한 tank를 사용하면

MissingReferenceException: The object of type 'PlayerController' has been destroyed but you are still trying to access it.

Your script should either check if it is null or you should not destroy the object.

PlayerController.OnKeyboard () (at Assets/Script/Managers/PlayerController.cs:88)

InputManager.OnUpdate () (at Assets/Script/Managers/InputManager.cs:16)

Managers.Update () (at Assets/Script/Managers/Managers.cs:33)

라는 문구를 출력하네요. 이건 코드 자체에서 삭제 후 삭제한 개체에 접근할 수 있는 여지가 있다는 뜻 같은데 어떻게 해결하면 될까요? 

답변 2

·

답변을 작성해보세요.

0

강동훈님의 프로필

강동훈

질문자

2021.01.07

답변 감사합니다.

0

해당 에러만 봐서는 어느 부분에서 문제가 일어난건지 확실히 알기 힘듭니다.
수업과 다르게 코드를 작성했거나, 유니티 버전이 다르거나,
프리팹을 다르게 만들었거나 다양한 이유가 있을 수 있습니다.

두번재 문제 또한 생명주기 관리에서 다 삭제한 다음 사용할 때 발생하는 문제인데
역시나 정확한 코드를 보지 않으면 알 수 없습니다.

고민해보시고 해결이 안 되면 rookiss@naver.com로 프로젝트 압축 후 보내주시면 살펴보겠습니다.