Changes to prefab parameters not being saved

In Unity 3.5.0b6 I have a script attached to a prefab with some Serialized floats.
When I change the floats in the unity editor, they update fine. But any changes I make are not saved to the .prefab file

I’m not sure I completely understand your problem, but if it’s something like this:

You have a Player prefab with a PlayerStats.cs script attched to it
PlayerStats.cs has a maxHealth attribute which was originally 100, but now you edited it so that it’s 50
You expect the Player prefab to update maxHealth to 50, but it doesn’t :frowning:

Then try commenting out the attribute in the script, going back into the Unity editor (pulls in the script, removes the attribute from the prefab), then go back to the script and un-comment it, then go back into Unity and it should pull in the new script with the new value for the attribute.

You can change the floats in your script to the “correct” value, then select the prefab in ProjectView and chose revert to Prefab.

I’m seeing something similar when I convert a project from 3.4.2… some of my prefabs are “going stock” and reverting to default settings across the board.,

Maybe this discussion is helping? They suggest calling EditorUtility.SetDirty(arg) when using Editor scripts to modify prefabs/prefab instances: http://unity3d.qatohost.com/questions/62455/how-do-i-make-fields-in-the-inspector-go-bold-when.html

I’ve found a solution to similar problem:

  1. Make some changes in the prefab instance using editor script.
  2. Unlink prefab instance: PrefabUtility.DisconnectPrefabInstance(yourInstance);
  3. Link it with its prefab again: PrefabUtility.ReconnectToLastPrefab(yourInstance);

After these manipulations it can be saved well and shows in bold in editor, and instances holds all their links.

If you are changing the serialized values by script…
Calling UnityEditor.PrefabUtility.RecordPrefabInstancePropertyModifications(YOUR_COMPONENT) on your instance’s component will solve this problem. Note that if you want the Editor to detect the scene change you also have to call UnityEditor.EditorUtility.SetDirty(YOUR_INSTANCE) as well.