When I modify and save a prefab the .unity scene file also changes. Why?
In a team environment we need multiple people to be able to make changes to prefabs without having to modify the scene itself. Is this possible?
For example -- after changing a single numeric property of a prefab, six instances of which are in my scene, I looked at the modified scene file with a hex editor. It appears that Unity saves all the properties for each instance of a prefab, even if the property has not been modified from the original prefab value -- I found six numeric changes matching my edit. In addition, there are lots of other unidentifiable changes in the scene file, in what look like 16-byte GUIDs, perhaps asset references?
This begs the question of what happens if my prefab is instanced in more than one scene? Since only one scene is open in the editor, these other scenes won't be changed until later when they are loaded. Which makes it seem that the changes in the scene aren't necessary -- in fact I reverted the scene file in version control and it still loaded fine and got the new prefab settings. So if it doesn't need to be changed then why change it? Is it safe to ignore these changes?
Any advice on team-based prefab workflow is appreciated. (I've just upgraded to Unity 3.3 Pro, and enabled external version control, but I believe the same issue applies to Unity Free.)
asked Mar 19 '11 at 12:19 AM
Yes, you can change the prefab in the Project view, without having to save the scene afterwards. We use that all the time, and it is a vital feature when several people are working on the same scene - we split sections of the scene into individual prefabs, which can be worked on and uploaded to the Asset Server individually, without the need for everyone to modify and update the scene as well.
When loading a scene, Unity updates any prefab changes on-the-fly, and integrates information about all(?) of the prefab's settings and parameters into the scene, even if they are unmodified default values. Therefore the scene is shown as modified, although nothing vital actually has changed.
Only if you do any local modifications to the prefab instance in your scene, or if you apply any previous local modifications do you need to save the scene as well.
This should also work if you change a prefab in the Project view that already has local modifications in one or more scenes.
answered May 24 '11 at 09:34 PM
My guess is since prefabs are an editor only feature in the end all prefab values will end up in the corresponding scenes at building time. There is still the original GameObject in the asset-database that will be used when you invoke Instantiate with a prefab reference but the prefab linkage is no longer available at runtime.
I think the changes won't hurt. As I said i think the changes will be made anyway to all scenes when you build your game. In the scene you always have the option to override any prefab values. These changes will also be saved in the scene.
answered Mar 19 '11 at 12:55 AM