Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

HideFlags.DontSave

Discussion in 'Scripting' started by liortal, Nov 19, 2014.

  1. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,555
    Hey,

    I need a solution that will keep some "junk" objects getting saved with a scene.

    It seems that setting the object's HideFlags to DontSave is a valid option (http://docs.unity3d.com/ScriptReference/HideFlags.html).

    According to the documentation, when using DontSave -
    Why won't the object be destroyed? the only behaviour i'm after is that it won' be saved to the scene. Why is this mixed with another behaviour, and what is the usage for that ?
     
  2. Landern

    Landern

    Joined:
    Dec 21, 2008
    Posts:
    354
    Perhaps between scenes you wanted a permanent testing GameObject or set of GameObjects that wasn't saved with the scene(you think you've got the scenes setup the way you want), but you didn't want to add every time or at least during this test cycle. Lets say there were 100 or even 1000 of these objects and again you wanted to test multiple scenes without recreating them, setting the properties, etc. Seems like a valid use case.
     
  3. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,555
    What if i simply want an object to be excluded when saving a scene ?
    I would expect the behaviour of keeping an object between scenes to be separate from the one for not saving it at all.

    Also, suppose i accidentally added this object in the editor, setting the hide flags from a script's Awake() or any other function won't work as the game did not execute yet (only after running it in the editor).
     
  4. Landern

    Landern

    Joined:
    Dec 21, 2008
    Posts:
    354
    Look, you're getting into more advanced parts of the editor, you should have an expectation that you may have to do more of the heavy lifting.

    Set it to ExecuteInEditMode(http://docs.unity3d.com/ScriptReference/ExecuteInEditMode.html) and move on. I'm sorry you don't agree with how UT setup their methods, you can certainly ask for a feature to be added(http://feedback.unity3d.com/), fact is you know what you've got, guess you have to deal with it.
     
  5. hpjohn

    hpjohn

    Joined:
    Aug 14, 2012
    Posts:
    2,190
    Monobehaviours have a Reset() method for editor execution
     
    liortal likes this.