- Home /
Updating a prefab fbx or animation while using version-control is broken
Our project is being developed by a small team, so we are using version control software (Perforce) with Unity Pro. We have set up our file versioning to behave as suggested by this page:
http://unity3d.com/support/documentation/Manual/ExternalVersionControlSystemSupport.html
Most of our game objects are instances of prefabs. When one of our artists updates an FBX or an animation file, updates the prefab, then checks in the changes, those changes cannot be seen by anyone else.
In the case of an updated FBX, the new version of the model simply is not seen in the prefab. The old version of the model is still visible. The user must manually re-apply the FBX to the prefab, and then the new model shows up. (However, the preview window still shows the old version of the model)
In the case of an updated animation, the prefab often says "Missing Animation Clip" in the Animation section. The user must manually browse for the animation to re-associate it with the prefab.
I discovered one bit of information about the missing animation problem. I opened one of the problematic prefab files in a text editor and saw some references to locally cached animations: "library/metadata/3b/3b9331fc2712fb04a96b1dff65d4a798...assets/soldier@die.fbx". We're not even doing version control of the "library/metadata" folder, so it seems questionable that the prefab is directly referencing this data.
At any rate, the prefabs seemingly work fine for the artist that is modifying the model or animation. There is only a problem when someone else tries to see the changes. While it is POSSIBLE to fix this locally on each user's machine for each piece of artwork every time a revision is made, it certainly is not a desirable workflow.
Has anyone figured out any way to reliably use prefabs in conjunction with version control software? I have seen a few posts about this, but the answers are generally work-arounds that involve re-exporting art locally or re-creating prefabs every time the art is updated. Are prefabs just not designed to ever be modified?
Answer by Ben 14 · May 02, 2011 at 06:06 PM
As far as I can tell, this is not related to using version control. We've always witnessed strange behaviour when updating FBX assets that are instantiated inside prefabs. I guess that what Paulus Liekis says in a comment to the other answer is probably correct, meaning that changes to an FBX inside a prefab may be correctly replicated as long as the update only changes the vertice/faces/materialIdxs of the mesh, but not if it is the bones or subobjects (adding/removing animations, I'm not certain of also). This is linked to the fact that Unity does not handle nested prefabs I guess - which is a pity really.
Anyway, what we do is maintain a clear separation on the fbx within the prefabs - they are never the parent of anything, nor referenced explicitely in the scripts in their parent (references are usually rebuilt at runtime through a GetComponentInChildren), so that when an FBX is updated, we may erase its instance(s) in the prefab(s) and recreate it. For our most recurrent cases we store the prefab next to the fbx with the same name, so that it's easy to parse all fbxs, get the prefabs that uses them, and apply that destroy/recreate/apply automatically through an import script. This is done only once after the fbx reimport - preferably by the artist who modified the fbx - and once committed to perforce everybody get the correct version.
Admittedly, that's far from ideal, but we manage to live with it with a 15+ team.
Hope this helps,
Ben
Answer by Paulius-Liekis · Nov 18, 2010 at 08:27 AM
Do you have .meta files enabled (i.e. "external source control" in editor settings)? - IIRC, when having .meta files enabled you shouldn't have to care what's happening in library folder. Are you sure your prefab connections are not broken?
I used Perforce with Unity and I can't remember having problems like this.
I've had the same problem. Animations will update but not geometry changes (to .fbx files)
As far as I know it should work. The only thing that doesn't work is if you add more nodes to your fbx - they won't be added to the prefab, but animations and meshes should be updated. If it doesn't, then please raise a bug and attach $$anonymous$$i project (with initial model) and a file with which model should be overridden.
Answer by Davo 1 · Dec 12, 2011 at 02:43 PM
Man, I put my vote in for this to be the #1 fix I would like to see to Unity! Allow artists to update models and have prefabs pick up the changes.
I got kicked hard with this issue- after building a really fun game over the course of a few weeks with temporary graphics, time came to update to real art and boom! Models dissapearing, turning to vertex pizza, and pain, pain, pain. Since I built everything in prefabs, It now looks like I have to manually go through and recreate absolutely everything. Yay.
I am worried about commiting all that time unless the workaround is solid...
So I create a null parent and put all my scripts in that, then at START() instantiate the model which I link in. I suppose I could put in a temporary mesh in the heirarchy that I delete on START so I can see where the model is being placed in the editor, right? Then on start, hunt down the bones I need to attach weapons, colliders and particles to by name?
Does anyone have an example chunk of prewritten java for this?
Answer by sreedhar3d · Mar 20, 2015 at 05:54 AM
This is not a Unity issue,
The first Fbx when you export that should be clean (Optimized and delete BindPose in Maya)
and next time you need to use the same maya file and update any model change do the same (Optimized and delete BindPose in Maya). Then your prefab works fine.