Search Unity

[Bug] Unity throws "Can't destroy Transform..." error when closing a scene containing a DontSave obj

Discussion in 'Editor & General Support' started by Xtro, Jan 25, 2021.

  1. Xtro

    Xtro

    Joined:
    Apr 17, 2013
    Posts:
    608
    Unity throws "Can't destroy Transform component of..." error when closing a scene containing a DontSave object with a child.

    Bug report: http://fogbugz.unity3d.com/default.asp?1309142_u0o062268r7thota
    Issue tracker: https://issuetracker.unity3d.com/is...-that-contains-a-dontsave-prefab-with-a-child

    See the simple script in the attached project zip.

    Repro steps:
    1) Open SampleScene.
    2) See a cube with a sphere child in the scene: These objects aren't saved to the scene. They are instantiated with "DontSave" flag in NewBehaviourScript.Awake method.
    3) Open EmptyScene.
    4) See the error in the console: This error happens when closing SampleScene.

    Error message:
    Can't destroy Transform component of 'Sphere'. If you want to destroy the game object, please call 'Destroy' on the game object instead. Destroying the transform component is not allowed.
     

    Attached Files:

    Last edited: Jan 27, 2021
  2. Xtro

    Xtro

    Joined:
    Apr 17, 2013
    Posts:
    608
    Unity QA team's response:

    Thank you again for reporting this issue. It seems that the issue was fixed in 2021.1.0a7 and up, but the issue still persists in 2018.4, 2019.4, and 2020.2 streams. We will be opening requests to backport this issue to those streams, but there's no guarantee that the issue will be backported.