+2018.03.17 > 2017.3.1p3 이후로 버그 수정 되었습니다.
(977568)(968882) – Physics: Fixed disabling and enabling a collider on an inactive gameobject producing transform error messages.
예전에 유니티 2017.1에서 상위 버전으로 올라오면서 전에는 없던 오류가 발생해서 버전을 안 올리고 있었는데 이번에 올린 뒤에 이유가 뭔가 한참을 헤매다 원인과 해결(정확히 말하면 회피) 방법을 알게 되어 같은 오류를 접하시는 분들의 시간 단축을 위해 몇 자 적습니다. ;ㅁ;
먼저 오류 메시지를 보면 다음과 같습니다.
Assertion failed: Transform has SetIsDispatchInterested present when destroying the hierarchy. Systems must deregister themselves in Deactivate. 0x00000001412F36C6 (Unity) StackWalker::GetCurrentCallstack 0x00000001412F423F (Unity) StackWalker::ShowCallstack 0x00000001411B3C20 (Unity) GetStacktrace 0x00000001406DA313 (Unity) DebugStringToFile 0x00000001406DAAF1 (Unity) DebugStringToFile 0x00000001408C1CDB (Unity) ValidateInterestedSystemsIsEmpty 0x00000001408C748E (Unity) Transform::MainThreadCleanup 0x00000001403B66BE (Unity) delete_object_internal_step1 0x00000001406F7762 (Unity) CommitBatchDelete 0x0000000140712145 (Unity) DestroyGameObjectHierarchy 0x000000014071B0EA (Unity) DestroyObjectHighLevel 0x0000000140CBB1A9 (Unity) DestroyObjectUndoable 0x00000001410F0270 (Unity) DeleteGameObjectSelection 0x0000000039A061CA (Mono JIT Code) (wrapper managed-to-native) UnityEditor.Unsupported:DeleteGameObjectSelection () 0x0000000039A060DE (Mono JIT Code) [SceneHierarchyWindow.cs:1097] UnityEditor.SceneHierarchyWindow:DeleteGO () 0x00000000398D9237 (Mono JIT Code) [SceneHierarchyWindow.cs:816] UnityEditor.SceneHierarchyWindow:ExecuteCommands () 0x00000000398C7696 (Mono JIT Code) [SceneHierarchyWindow.cs:403] UnityEditor.SceneHierarchyWindow:OnGUI () 0x00000000028A74F2 (Mono JIT Code) (wrapper runtime-invoke) object:runtime_invoke_void__this__ (object,intptr,intptr,intptr) 0x00007FFCE35C64CF (mono) [mini.c:4937] mono_jit_runtime_invoke 0x00007FFCE3518A49 (mono) [object.c:2623] mono_runtime_invoke 0x00007FFCE351EF57 (mono) [object.c:3838] mono_runtime_invoke_array 0x00007FFCE34DD343 (mono) [icall.c:2750] ves_icall_InternalInvoke 0x0000000002870AB7 (Mono JIT Code) (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (object,object[],System.Exception&) 0x000000000286EC12 (Mono JIT Code) [MonoMethod.cs:222] System.Reflection.MonoMethod:Invoke (object,System.Reflection.BindingFlags,System.Reflection.Binder,object[],System.Globalization.CultureInfo) 0x000000000291B6EF (Mono JIT Code) [MethodBase.cs:115] System.Reflection.MethodBase:Invoke (object,object[]) 0x000000001561B205 (Mono JIT Code) [HostView.cs:295] UnityEditor.HostView:Invoke (string,object) 0x000000001561B0AA (Mono JIT Code) [HostView.cs:288] UnityEditor.HostView:Invoke (string) 0x00000000193CD360 (Mono JIT Code) [HostView.cs:255] UnityEditor.HostView:InvokeOnGUI (UnityEngine.Rect) 0x00000000193AD277 (Mono JIT Code) [DockArea.cs:398] UnityEditor.DockArea:OldOnGUI () 0x0000000019399D48 (Mono JIT Code) [IMGUIContainer.cs:182] UnityEngine.Experimental.UIElements.IMGUIContainer:DoOnGUI (UnityEngine.Event) 0x0000000019398DC0 (Mono JIT Code) [IMGUIContainer.cs:338] UnityEngine.Experimental.UIElements.IMGUIContainer:HandleIMGUIEvent (UnityEngine.Event) 0x00000000155FD120 (Mono JIT Code) [EventDispatcher.cs:357] UnityEngine.Experimental.UIElements.EventDispatcher:DispatchEvent (UnityEngine.Experimental.UIElements.EventBase,UnityEngine.Experimental.UIElements.IPanel) 0x000000001937786F (Mono JIT Code) [UIElementsUtility.cs:256] UnityEngine.Experimental.UIElements.UIElementsUtility:DoDispatch (UnityEngine.Experimental.UIElements.BaseVisualElementPanel) 0x000000001937733B (Mono JIT Code) [UIElementsUtility.cs:78] UnityEngine.Experimental.UIElements.UIElementsUtility:ProcessEvent (int,intptr) 0x0000000019376E5D (Mono JIT Code) [GUIUtility.cs:175] UnityEngine.GUIUtility:ProcessEvent (int,intptr) 0x000000001937701E (Mono JIT Code) (wrapper runtime-invoke) <Module>:runtime_invoke_bool_int_intptr (object,intptr,intptr,intptr) 0x00007FFCE35C64CF (mono) [mini.c:4937] mono_jit_runtime_invoke 0x00007FFCE3518A49 (mono) [object.c:2623] mono_runtime_invoke 0x0000000140A2E95C (Unity) scripting_method_invoke 0x0000000140A2215A (Unity) ScriptingInvocation::Invoke 0x0000000140A2320A (Unity) ScriptingInvocation::Invoke<bool> 0x000000014028170E (Unity) IMGUIScriptingClasses::ProcessEvent 0x000000014112D0AF (Unity) GUIView::ProcessRetainedMode 0x00000001413FC188 (Unity) GUIView::OnInputEvent 0x000000014112CF4C (Unity) GUIView::ProcessInputEvent 0x00000001413F309D (Unity) ExecuteCommandOnKeyWindow 0x00000001413F425E (Unity) GUIView::ProcessEventMessages 0x00000001413FE14A (Unity) GUIView::GUIViewWndProc 0x00007FFD17D3B85D (USER32) CallWindowProcW 0x00007FFD17D3B1EF (USER32) DispatchMessageW 0x00000001414114D0 (Unity) MainMessageLoop 0x0000000141412DEC (Unity) WinMain 0x0000000141E65958 (Unity) __tmainCRTStartup 0x00007FFD16361FE4 (KERNEL32) BaseThreadInitThunk 0x00007FFD18C9EFC1 (ntdll) RtlUserThreadStart
Assertion failed: Transform has SetIsHierarchyDispatchInterested present when destroying the hierarchy. Systems must deregister themselves in Deactivate. 0x00000001412F36C6 (Unity) StackWalker::GetCurrentCallstack 0x00000001412F423F (Unity) StackWalker::ShowCallstack 0x00000001411B3C20 (Unity) GetStacktrace 0x00000001406DA313 (Unity) DebugStringToFile 0x00000001406DAAF1 (Unity) DebugStringToFile 0x00000001408C1D22 (Unity) ValidateInterestedSystemsIsEmpty (이하동일)
계층 상의 transform을 파괴하는 중에 SetIsDispatchInterested와 SetIsHierarchyDispatchInterested Assertion(표명)이 실패했으며, 시스템은 반드시 비활성 상태에서 스스로 등록 해제(취소?)해야 한다는 소리인데 내부적인 말이라서 정확히 뭘 하라는 건지는 모르겠네요.
일단 Assertion이 실패했다는 말은 참이 나와야 하는 상황에서 작성자의 의도와 다르게 거짓이 나왔다는 소리이기 때문에 내부 버그로 보입니다. 해당 버그는 2017.2 이상 버전에서부터 발생하는 것으로 보이고, 해당 메시지를 보려면 collider가 있는 gameObject를 스크립트에서 SetActive( false );를 하거나 에디터에서 직접 끈 뒤에 스크립트에서 collider의 enabled를 true로 하거나 에디터에서 (켜져 있다면 껐다가 다시) 직접 켠 뒤에 해당 gameObject를 파괴(삭제)하면 볼 수 있습니다.
gameObject의 activeSelf 참, 거짓 여부와는 상관없이 activeInHierarchy가 false인 상태에서 collider를 true로 만들고 파괴하면 오류가 발생합니다. 유니티 최신 패치 버전(2017.3.1p2)에서 해봐도 오류가 나오는 걸 보니 아직 버그 수정이 되지 않은 것 같네요. (2017.3.1p3 이후 버그 수정됨)
이를 회피하기 위해서는 collider가 켜져 있고 activeInHierarchy가 false인 gameObject가 파괴되기 전에 다음과 같이 collider를 꺼주면 됩니다.
void OnDestroy() { if ( gameObject.activeInHierarchy ) { return; } Collider collider = gameObject.GetComponent<Collider>(); if ( collider ) { collider.enabled = false; } }
참조
https://forum.unity.com/threads/assertion-failed-transform-has-setisdispatchinterested-present-when-destroying-the-hierarchy.505111/