Search Unity

Are HideFlags changes supposed to be saved in scene and prefab?

Discussion in 'Scripting' started by Michael-Ryan, Jan 30, 2019.

  1. Michael-Ryan

    Michael-Ryan

    Joined:
    Apr 10, 2009
    Posts:
    184
    I'm using Unity 2018.3.0 with an old project that I've upgraded from Unity 5.x.

    I have some objects that make up the scene. These objects are only needed during the content creation process, but are not needed in the final build. I would like to set their HideFlags with DontSaveInBuild, which I believe should exclude them automatically when the standalone builds are made.

    I am able to set the HideFlags on the game objects, and also set other hide flags (i.e., NotEditable) on various components, however those changes don't seem to be saved to the scene or prefabs.

    Are HideFlags meant to be serialized and saved in the scene and prefab asset files? Or are they only intended for use in the editor and during the editor session in which they are set? Is it possible to set the HideFlags on a scene game object, save the scene, and then reload the scene (possibly during a later Unity session) and have those HideFlags still be set?

    At this time, it seems like the HideFlags need to be set on the scene objects when each scene loads. I'm hoping this isn't the way we're expected to use HideFlags.

    I've tried setting the HideFlags on prefabs, and the data doesn't seem to be included in the serialized prefab (.prefab) files when those assets change either.