- Home /
FormerlySerializedAs and Prefabs
I noticed a strange behavior with the FormerlySerializedAs attribute and prefab. Consider the following script snippet:
public class MLSerializeTest : MonoBehaviour {
public float s;
}
I attach it to 2 GameObjects (test and testPrefab) with nothing else, I create a prefab out of testPrefab, and set the values to something other than zero in both scene objects. Then, I change the script:
public class MLSerializeTest : MonoBehaviour {
[FormerlySerializedAs("s")]
public float sNew;
}
I go to the scene and the values appear correctly. I close the editor, open it again and while the test still has the changed value, testPrefab's s value in the scene is now zero.
not sure but maybe you forgot to press button "apply" on prefab instance?
I don't want apply the change to the prefab. I want to keep the modified instance in the scene as it is before the field rena$$anonymous$$g takes place.
Sounds like a bug to me, you should file a bug report with a repro scene
Your answer
Follow this Question
Related Questions
Is there a way to save a procedurally-generated mesh on the client machine? 1 Answer
Script variable reverted to prefab when hit play. 1 Answer
Can I create a GameObject( or preferably a Prefab) that won't update a nested prefab? 0 Answers
Best approach to one-time generation: Assets, Serialization or manual labor? 1 Answer
Why does the prefabOverride not work on fields marked as SerializeField? 0 Answers