Search Unity

Getting "Can't destroy Transform component" when exiting play mode

Discussion in 'Scripting' started by Wahooney, Jul 31, 2018.

  1. Wahooney

    Wahooney

    Joined:
    Mar 8, 2010
    Posts:
    281
    Hi,

    Firstly to be clear: My code is not calling Destroy() any transforms here. This is happening outside of my scripts as you can tell from the Full Trace below. I'm doing nothing special to this object, and my RescueArea object is the only one that has this issue.

    Can't destroy Transform component of 'RescueArea(Clone)'. If you want to destroy the game object, please call 'Destroy' on the game object instead. Destroying the transform component is not allowed.
    0x0000000141535168 (Unity) StackWalker::GetCurrentCallstack
    0x000000014153B6A6 (Unity) StackWalker::ShowCallstack
    0x000000014140A88B (Unity) GetStacktrace
    0x00000001408AF040 (Unity) DebugStringToFile
    0x00000001408FC201 (Unity) DestroyObjectHighLevel
    0x0000000140987522 (Unity) DestroyWorldObjects
    0x0000000140E5DE25 (Unity) EditorSceneManager::RestoreSceneBackups
    0x0000000141438B78 (Unity) PlayerLoopController::ExitPlayMode
    0x0000000141444FAF (Unity) PlayerLoopController::SetIsPlaying
    0x000000014144855D (Unity) Application::TickTimer
    0x00000001415E66C5 (Unity) MainMessageLoop
    0x00000001415E8AAC (Unity) WinMain
    0x000000014242A9EA (Unity) __scrt_common_main_seh
    0x00007FFBC7433034 (KERNEL32) BaseThreadInitThunk
    0x00007FFBC7761431 (ntdll) RtlUserThreadStart

    Any ideas?

    Thanks!
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,674
    Are you doing anything with RescueArea in Monobehavior message functions like OnEnable, OnDisable, OnApplicationQuit, etc.? That can cause issues, although there are workarounds. It's also possible your RescueArea object has some other script on it misbehaving.

    Actually, it sorta looks like it might be a Unity serialization bug, given that it is triggered from the EditorSceneManager.RestoreSceneBackups script. You might try a reimport all.