prefab relationship to asset mesh lost ?

I’m on lightwave… I’ve exported to fbx using layout…

then I’ve created a prefab and created an instance in the scene…

Alls going well… I’ve gone back to the 3d mesh in lightwave modeler, modified it, exported it from Layout in fbx and unity updates the instance…

Everything going great, except.

Twice now it’s not updated, the asset mesh shows the new layer names and meshes, but the prefab doesn’t and the instance in the scene doesn’t…

Last time it happened I lost all my work as I updated the prefab :frowning:
As it’s now happened again I’m sat here frozen as I’ve no idea what to do, and I’ve no wish to attach all my scripts again and retranslate/rotate meshes back into position…

Twice in 2 days this as happened

Any help ?

Simon

I’ve seen the same kind of thing with 3DSMax and FBX export as well as Maya .mb file imports into Unity. From what I’ve seen, moving any vertices or any new or changed vertex weighting (for characters, etc.) will always update fine. However, most time adding new items to the mesh or moving a whole mesh (not the vertices themselves) will not result in an auto update.

Your changes are still there in the file, they’re just not in your scene prefab. Unfortunately, the only way we’ve found to get them back into Unity is to re-create the prefab again from the mesh file.

To be clear, if you have your old unchanged prefab and you put it in the scene, then update your .fbx file and don’t see any proper change, if you find the .fbx file in the project window and drag it into the scene you will (or at least should, we always do) see the proper changes, so you essentially have to destroy your old prefab and remake it. Anyone else know of an easier way I’d like to know too :slight_smile:

I have to be able to modify my mesh…

If it’s a case of you can’t for fear of losing all the work one’s done with regards script attachments, translation and rotations of meshes… then it’s a show stopper.

:frowning:

Simon

I know… it’s more than just a bit annoying, it’s a downright pain. But that is what we’ve had to do with our characters and a few other environment meshes that needed more than minor revisions as well. Again, if anyone else also knows another way I’d be glad to know myself as well.

You probably broke the connection to the prefab in the scene.
Unity warns you about this when it happens, by bringing up a dialog saying Do you really want to break the prefab connection.
Once you break the prefab connection, new meshes or their positions will no longer be tracked in the prefab instance.

Usually you try to not add components or modify the hierarchy inside of the prefab instance in the unity scene. This way the prefab connection will not be broken. Instead a parent object has all the behaviour scripts attached.

If you have already broken a prefab connection and want to connect it again you can alt drag the prefab onto the instance.

if you simply change a mesh it will update the prefab because you’ve altered the mesh filter that the prefab points to but by adding a new layer in lightwave you’ve added a new object. the prefab doesn’t know that you wanted to add it to the prefab too. it only contains what you put in it when you made it and the new mesh filter did not exist then.

if your links to the prefab are still intact you should be able to drag the new layer onto an in-scene object. this will break the prefab link for that instance and you may need to fix rotation and position of the new layer if you’ve changed that in unity (it imported using lightwave’s transform). once you have it set, upload changes to prefab through the game object menu. any other instances should update if their link to the prefab hasn’t been broken. back up often :slight_smile:

I understand I can break a link between the instance in a scene and it’s originating prefab.

What I don’t understand is how the link between the asset prefab and the asset lightwave fbx mesh gets broken ?

This is what’s occurred, and no warning is given that this might occur…

[edit]

So adding an extra layer in my lightwave fbx mesh causes the problem as the prefab doesn’t track new layers ?

Is there anything else the prefab doesn’t track in my mesh if made after the prefab was made ?

Simon

it’s not. you made the prefab without the new layer because it didn’t exist. the new layer is actually a new object. unity won’t add a new object to a prefab automatically. it will update any mesh filters that already exist in the prefab.

I agree with Bomber in that essentially the mesh link is being broken. When a change to a mesh asset is made and Unity does ‘updating assets’ it should pull in any new information or changes from the mesh file. It doesn’t really do that… it only updates any changes to what already existed in the prefab (moving verts, adjusting vertex weights). The new meshes (even new mesh/tris added to a single whole object) exist and are updated in the .fbx file when you pull that into the scene again, but they do not update into the prefab. You don’t have to break the prefab for this non-update to happen, so as Bomber also said you’re never informed.

I have to say the alarm bells and flashing lights are going off here…

In one hand I have this wonderfull productivity tool that makes certain things real easy and time saving…

And in the other hand I’ve got this restriction that I can’t change my 3d mesh, I can’t add to it, improve it over time… without having to recreate a new prefab and manually (time consuming) add all those scripts, rotations, translations, textures types… etc…

Am I understanding it correct ?

Simon

If your new mesh asset has an additional GameObject added to it which was not present when the Prefab was created, you can do a couple of things to get back to where you were.

  1. Add a new child GameObject to the Prefab, and attach the new mesh to that GameObject. This will basically make your prefab emulate the structure of the asset file when imported by Unity.

  2. Put the new layer back in the old layer. Then Unity will detect the new mesh data within the same mesh filter attached to the Prefab, and it should “just work”

  3. Rebuild the whole prefab with the new mesh asset as a base. This is the least fun way to do it, but it may be the most direct path.

Of course, the best thing to do is build the assets in a way that does not create multiple child GameObjects. Or know how many child GameObjects you’re going to have, and account from them from the beginning. I think most of us (myself included) did not know that Lightwave layers create new GameObjects. So maybe this scenario was unavoidable. But hey, that’s why we all learn together, right?

I thought I’d post an image… Now please ignore the UV map issues, as I’ve taken the opportunity to bring the Lancaster’s UV’s into line with the B17 and B24’s… it means until I go redo the texture image it looks a bit odd, but I’ve bigger fish to fry at the moment.

Now I’ve used both views to show ‘project’
the top view shows the Lancaster prefab.
the bottom view shows the Lancaster lightwave fbx mesh and as you can see the new layer ‘cockpit glass’ doesn’t exist in the prefab…

Now interestingly the 303 mid-upper turret was added at a later date from when the prefab was created…
What happened here was that I created a new separate mesh solely for the turret (centered at 0,0,0). I then added it to a new prefab I’d created, created an instance of it in the scene and then moved that instance into the Lancaster instance within the scene, then updated the Lancaster prefab from this Lancaster instance…

Simon

I totally agree with you… It’s why I’ve posted it up…

I’m sure there’s a way around this, and more heads are better than one.

So given the example in the screenshot above, what should I do ?

Simon

it does exactly that. you’re just not understanding how unity looks at the mesh file. in the prefab you have an object. that object has a mesh filter component. the mesh filter is the geometry for the object. if that mesh filter changes the prefab will update. adding a new object to your asset folder won’t automatically add it to a prefab. a new layer in a lightwave file is a new object with it’s own mesh filter. even though it’s parented under a root object in your assets, you haven’t given the prefab a reference to the new object and its mesh filter (it’s based on the object directly not the root). so it can’t update something it doesn’t know exists.

simon, try what i said… drag just the new layer onto an in-scene object and upload changes to prefab (back up first in case if you’re worried about it). again it uses lightwave’s transform. modeling each part at 0,0,0 means you have to manually assemble in unity. for the most seamless pipeline you would build the model with parts correctly positioned in lightwave. now when you bring in a new object, you can copy and paste the parent’s position/rotation and it will be correctly aligned with the rest (iirc you’d do this before parenting the new object otherwise it will transform relative to the parent).

Ok… I see now that Lightwave acts a bit differently, but I’m using 3DSMax and I get the same kind of things.

If I add new tris/quads to a mesh that already was built into a prefab and then update the exported .fbx file with the new tri/quad info, if I drag the updated .fbx file into the scene by itself I will see the changes, but the prefab that contains the .fbx file will not update the changes. I can move existing verts around and re-weight them and those changes will update through to the prefab, but new geometry will not even for a single GO.

Now granted, Lightwave is making whole new objects which is different… but for me with 3DSMax → .fbx it’s still breaking the link to the mesh within the prefab.

it should update. double check that the prefab is pointing to the correct mesh filter. if it is, post a sample or file a bug report.

As has been said above, if you break the prefab connection then adding new meshes to the fbx file will not automatically propagate into the prefab instance.
A prefab connection breaks when you add components to the instance. If the prefab connection is not broken, new meshes and all changes will automatically propagate into any scene where you have those instances.

If the prefab connection is broken eg. because you removed / added a component in the prefab instance, then new meshes will not be added to the instance automatically.

The solution is to make sure you don’t break the prefab connection of the instantiated prefab. There are many ways to do that.

Solved it !!!

Happy New Year :slight_smile:

ok ok… I’ll spill the beans.

I selected the new mesh (lightwave layer) from the lightwave fbx asset in the project view and dragged it into the scene at the very top… I then had to drag the material to it from project view… then I parented it correctly in the scene window within the Lancaster game object under the cockpit bars…

Then I updated the prefab…

phew :slight_smile:

This I can live with…

Simon

This is not what is happening… I am not doing anything that you have written above…

I am working solely in my 3d application… and when coming back to unity finding the prefab derived from the mesh is not being updated with new meshes.

This is clearly an unexpected lightwave/fbx/unity relationship thingy and I’m glad I have a work-around, so as I can continue to explore more of unity without worrying anything I do I’ll lose if I improve my model…

Learning is fun…

Regards

Simon

just to clarify for wavers, the lightwave specific issue is when you add a layer to a model in lightwave then export to fbx. an existing prefab will not automatically include the new layer(object) simply because it’s parented under the fbx asset. it won’t update in this case even if the prefab link is intact. you have to manually add the new object to the prefab.

glad you got it solved, simon. happy new year to you!