x


Can I change a prefab without changing the scene?

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.)

more ▼

asked Mar 19 '11 at 12:19 AM

yoyo gravatar image

yoyo
6.4k 25 39 84

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

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.

more ▼

answered May 24 '11 at 09:34 PM

Wolfram gravatar image

Wolfram
9k 8 20 52

(comments are locked)
10|3000 characters needed characters left

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.

more ▼

answered Mar 19 '11 at 12:55 AM

Bunny83 gravatar image

Bunny83
45.5k 11 49 207

Yeah, I think you do get the option to 'save changes' but that weather you do save or not the data in the scenefile will be identical. The metadata will be different before saving though, but this doesn't matter.

Mar 19 '11 at 03:14 AM Joshua

The scene file isn't identical, and it isn't the same size. There are a substantial number of differences in the binary file. Looks like I'll end up implementing an auto-dump to text file at asset save time, so I can see what's changed in prefabs and in the scene. (Pity Unity doesn't natively serialize to a text format.)

Mar 19 '11 at 03:53 AM yoyo

Unity 3.5, yaml for scenes and prefabs, thanks UT! :-)

Apr 24 '12 at 04:38 PM yoyo
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1679
x1260
x719
x63
x51

asked: Mar 19 '11 at 12:19 AM

Seen: 2418 times

Last Updated: Apr 24 '12 at 04:38 PM