- Home /
GameObject HideFlags.DontSave not working as expected
I expected the following MonoBehaviour (tested in a blank project) to cause the GameObject to which it is attached to exist in the scene in the editor but not when the game is played. This does not appear to be how it works, although the manual is not clear on this.
The manual claims that when setting HideFlags.DontSaveInEditor:
"The object will not be saved to the scene in the editor."
Can anyone explain to me exactly what effect setting the HideFlags like this DOES have if not what I expected? And how can I go about achieving editor-only GameObjects if not like this?
[ExecuteInEditMode]
public class HideFlagsTester : MonoBehaviour
{
private void Start()
{
this.gameObject.hideFlags = HideFlags.DontSaveInEditor;
}
private void Update()
{
this.gameObject.hideFlags = HideFlags.DontSaveInEditor;
}
}
Answer by allenallenallen · Aug 14, 2015 at 03:36 PM
Use this instead?
http://docs.unity3d.com/ScriptReference/HideFlags.DontSave.html
HideFlags.DontSave objects will disappear once you switch scenes.
Thanks but I have also tried this too and the behaviour appears to be the same in this respect. Playing the game within the editor the GameObject remains.
Your answer
Follow this Question
Related Questions
Is it posible to edit MonoScript attributes from editor? 1 Answer
How do you save changes made with custom editor? 3 Answers
Storing data about an asset only in the editor 2 Answers
How do components(e.g transform) save data? 1 Answer
Add gameObject/transform to script component slot with editor 1 Answer