Search Unity

How to keep an object in edit mode?

Discussion in 'Editor & General Support' started by watsonsong, Jul 23, 2019.

  1. watsonsong

    watsonsong

    Joined:
    May 13, 2015
    Posts:
    555
    I instantiate a game object in edit mode, and set the hideFlags to `HideFlags.HideAndDontSave`.
    I want this object persistent when change scene, but each time I new a scene, it show a lot of error like this:
    `
    Can't destroy RectTransform component of 'BR'. If you want to destroy the game object, please call 'Destroy' on the game object instead. Destroying the RectTransform component is not allowed.
    `

    The game object seems destroy but the OnDestroy is not invoked.
    Is there any way to do the right thing? I try to destroy the object before opening a scene and re-create it when load finished. But the error happend before `EditorSceneManager.activeSceneChangedInEditMode`