- Home /
Prefab behaviour
just wondering if this is normal behaviour.
Prefabs hold any change to its public variables made during a play sesssion by a script.
Create any prefab with a simple script containing a public variable, create another runtime script modifying this prefab contained variable, exit back to editor and public variable will remain changed.
Is this because the variable being modified is not inside an instance but on the original prefab?
Thanks for any help
Answer by fffMalzbier · Apr 27, 2015 at 08:52 AM
A prefab is a saved asset version of a gameobject.
Every change done to a saved asset remains saved and is not reverted on stopping the game.
This is a intended behavior.
Is this because the variable being modified is not inside an instance but on the original prefab?
That is correct.
Thanks. Fair enough, just what seems strange is the saving which happens only when saving the scene, but actually prefabs are not strictly connected to the current scene. But this is another story.
Thanks again
Your answer
![](https://koobas.hobune.stream/wayback/20220613194122im_/https://answers.unity.com/themes/thub/images/avi.jpg)