Search Unity

Model translation does not update if model is in any kind of prefab

Discussion in 'Editor & General Support' started by LaralynM, May 29, 2014.

  1. LaralynM

    LaralynM

    Joined:
    Sep 30, 2013
    Posts:
    24
    I've hit a snag that seems to have no reasonable work around. Repro steps:

    Create a simple model, like a cube with a sphere over it. Export to FBX. In Unity, add the model to the scene, then drag it into the Project folder to make a prefab. Drag another copy of the original model into the scene for comparison. Go back to 3D app and lower the sphere, then export. In Unity, the original model updates but the prefab does not.

    I've confirmed this in both Blender and C4D. Mesh changes seem to update but translations of elements within the model do not. I've tried this all kinds of ways, from having the model attached to an empty game object before becoming a prefab all the way down to having the model itself as the prefab, and it seems consistent.

    Is this a bug or is it expected behavior? From an iteration stand-point, it's a significant issue.

    Thanks!
     
  2. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    I think this is "by design", if a bit unfortunate. Explanation on what's going on below. Strangely enough, I haven't ran into that particular problem myself yet -- maybe because most of the time I import models one by one from a 3D app, instead of whole hierarchy of them. Or if there's a hierarchy, then it's for "static geometry" that does not need turning into a prefab.

    Now, what I think is going on:

    In Unity, there's really no difference between "FBX file" and "a prefab". Both are hierarchies of game objects with components stuff (mostly meshes materials) attached to them. Another thing: in Unity there's no dependencies between any kinds of assets -- no asset can depend on the state of another asset (i.e. there's no way to know that "hey if that fbx file was changed, then these other assets need to be reimported as well").

    So what happens is:
    1) you import the fbx file from a 3D app - let's call this A. This results in some meshes, and some game objects with their transform positions etc.
    2) you drag that into the scene; the objects in the scene know "hey I'm coming from prefab (just a model file here) A, and these are the properties I have changed from whatever is in the prefab". Right now nothing is changed compared to prefab, except the position of the root game object.
    3) you create a prefab out of the same thing - let's call this B. Critical thing here: that prefab's game object hierarchy transform positions etc. are completely separate from the original fbx file A by now. They just don't know anything about each other anymore - there's prefab A and prefab B only. Some things are shared however - namely meshes materials (but transforms their data is not).
    4) now you put prefab B into the scene. The game objects of this in the scene know "hey I'm coming from prefab B".
    5) you change original model file A to move some objects around.
    6) A's instance in the scene changes - since the positions come directly from this prefab. But B is a completely separate prefab! It does not even know it came from A file; it has positions other component data as it they were set when you created it.

    So... that's what's going on. And yeah, for this particular workflow that's a bit unfortunate.

    I'm not even sure how people work around it TBH. Maybe they don't do it? Or maybe they don't create additional prefabs, but instead make all extra components scripts be attached directly to imported prefab A (using AssetPostprocessor.OnPostprocessModel)
     
  3. LaralynM

    LaralynM

    Joined:
    Sep 30, 2013
    Posts:
    24
    For some reason, I had in my head that I should use prefabs even for things without scripts on them, so while my problem remains, the impact of it is greatly reduced. Out of the hundreds of objects in my scene, only 30 or so have scripts attached to them... so manual updating isn't the chore it would be if all of them were prefabs!