|
I created a prefab and added functionality to it (scripts, colliders, rigidbody). After adding the components, I click "apply" to re-establish the prefab connection. But when I export an updated version of the fbx file that contains new objects, these do not show in Unity. If I drag the fbx onto the prefab, it gets overwritten and all added components disappear. Is there a workaround or an asset post-processor script that can help out here ? Seems to me that its a normal fact of life that during development objects get added. I can't believe that a workflow-oriented tool like Unity cannot handle this. [edit] To clarify my question, consider this workflow :
The second teapot is not added to the prefab. What workflow allows me to update the teapot prefab and keep the existing components ?
(comments are locked)
|
|
In general, I wouldn't recommend directly adding models to the scene and modifying them (which does break the prefab connection and as you have experienced - that's not so easy to fix in this specific case). Instead attach the models as child objects of empty game objects and attach any scripts and other components to this empty parent game object instead of to the model. That way, you can easily update your models without any problems. You can also create a Prefab from the parent object (and then use that instead of the actual model). You can see the difference between a "model pseudo-prefab" and a "real prefab" by looking at the icon (it looks a little different). You can easily access your "model game object" from the prefab ("parent game object") in scripts by adding a public GameObject member variable to those scripts. Like:
Then, all you need to do is drag the child object (which is your model) onto the slot in the property inspector of your script in the parent object (which is your prefab). Another nice thing about this approach: You can easily extend this without breaking all your scenes, e.g. you could include different poly-versions of the same model and then dynamically show/hide the different versions (as needed), which would be the foundation either for your own custom LoD (Level of Distance) implementation, or could also be used to dynamically switch models with different complexities based on framerate. If you use the models directly, and then at some later point in time decide you want to do something fancy, "conversion" might be extremely painful (been there, done that, got a T-shirt ;-) ). A very interesting approach, replacing geometry under a placeholder parent. However some components like colliders have to be put on the objects themselves, right ?
Dec 09 '09 at 10:54 PM
PatHightree
Depends ... mesh colliders - yes. But those would be generated on import anyways, so they should be available in the "model object". Other colliders can just as well be attached to the parent object. I'm not sure about rigidbodies, though - that's where the approach may hit a limitation (if you have to use the rigidbody with the mesh collider of the imported model). You could probably also attach a mesh-collider to the parent object and then select the correct mesh - but I doubt that will give you the desired results.
Dec 10 '09 at 07:49 AM
jashan
Attaching the rigidbody and mesh collider component with the correct mesh to the parent GO works just fine.
Dec 10 '09 at 09:26 AM
AngryAnt ♦♦
Thanks for the clarification, Emil!
Dec 10 '09 at 04:43 PM
jashan
Ok, that simplifies things. Seems like this might work out after all :) Thanks !
Dec 11 '09 at 05:11 PM
PatHightree
(comments are locked)
|
|
When you reexport your art, if the name of the mesh in the fbx hasn't changed, then your updates should be reflected without issue. When you say that the prefab does not show in Unity, does that mean that the mesh disappears? If so, check the inspector. Does it say Mesh Filter [None], Missing (Mesh)? That means you've somehow confused Unity... maybe by changing the name of the mesh?
(comments are locked)
|
|
We have a similar problem, everytime my graphic update me with his new levels, we are in a nightmare, because ONLY if I copy HIS "assets/library" folder I get their level right, but this is not gonna play good, with my project library folder and my levels! Is this perhaps somehow related to the internal importing library folder? This is not really related to the question, please don't thread-hijack. Just create a new question on the front page, thanks.
Dec 11 '09 at 05:16 PM
PatHightree
(comments are locked)
|

"Add components to the GameObject and/or teapot" - and/or won't work here. As soon as you add components to the teapot, you break the prefab connection and are up for trouble. It's best to simply not change the model object at all and apply any changes "one level up" (see my answer below for more details). If you don't change "teapot.fbx" inside Unity, adding objects should work (unless there's some oddities with the FBX importer here).
@Hightree, remember to upvote good answers also.
cross reference http://answers.unity3d.com/questions/15271/prefabs-workflow-changing-models-in-a-3d-app-after.html Greetz, Ky.