x


Prefabs Workflow - Changing models in a 3D app after they have been used in a prefab

Hi, I'd like to know what's the right workflow and how to use Prefabs for writing Unity games where its used meshes get updated by modelers (using Maya) while the game is developed in Unity.

I've got the following problem:

  • I build a model in Maya

  • I import the .mb file in Unity

  • I drag it from Project pane into Hierarchy pane

  • Create in the Project pane a Prefab

  • Drag the top level object from Hierarchy pane onto prefab in Project Pane

  • I (or any modeler) change the model in Maya and overwrite the model in the Asset folder

Now in the Project pane are two models: the one I originally imported and the prefab. After updating the model in Maya, the original model in the project pane changes (I can see the changes made to the model in the small preview window), but the prefab doesn't get updated, nor does the object in the Scene View (in the Hierarchy pane respectively).

How can we change geometries already in use by the Unity project afterwards?

more ▼

asked Apr 16 '10 at 04:17 PM

drhenry gravatar image

drhenry
395 11 11 23

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

7 answers: sort voted first

I have come up against this problem, and I currently work around it (to a certain degree) this way, by adding an extra step:

  • Build Model in 3D app

  • Import the .mb / .max / .fbx file in Unity

  • Create a new empty gameobject in your hierarchy

  • Drag your imported model onto the empty gameobject (so you model is a child of it)

  • Create a new prefab in your project pane

  • Drag the top-level empty gameobject (which has your model as a child) onto the new prefab

Now, I find this method works for mesh changes to the existing objects, but it still doesn't pick up any changes in transforms to the existing objects, or any additional new objects added to the original file.

I know this doesn't seem like much of an improvement; it still requires a manual update if any models were moved or any new models were added. However, because your model is now a child within the prefab, it becomes a lot simpler to delete & re-add your model to the prefab.

Before, if you had made a prefab with your model as the root object (as opposed to an empty GO), you would probably have added components, scripts and adjusted settings, and from that position, it seems that there is no way to update the model without losing all these components and their settings. You simply have to delete and re-make the prefab.

Wheras now, because your model is a child within the prefab, you would add your components and scripts to the empty base GO, and this means you can preserve that whole part of the prefab while just deleting & re-adding the visible model part (you'd do this to an instance in the hierarchy, then choose "apply" to apply your changes to the prefab).

Hope this helps!

more ▼

answered Apr 16 '10 at 04:49 PM

duck gravatar image

duck ♦♦
41k 92 148 415

This is what we do too, and for the same reasons. You may need to modify some of your scripts if they are expecting certain components to be in the root object. For example, if your scripts do GetComponent for a mesh or animation, you'll need to update those to search child objects too. Typically just do that in Start() and keep a reference to them so the rest of the script can refer to the right one.

Apr 16 '10 at 05:34 PM Molix

So there is no way to update a mesh in the Hierarchy pane, when a modeler changes position, scale etc. in Maya? And adding submeshes, replacing meshes and making meshes more detailed (triangle count) doesn't work either? What about Color? In all these cases you have to delete the object from Hierarchy pane, reimport it, drag it from Project pane to Hierarchy pane again and add all scripts and components to its child objects (if they can't be moved to the parent node) and modify the scene hierarchy again as it has been before?

Apr 19 '10 at 07:19 AM drhenry

Hm, I don't get it. In the Unity Video tutorial No. 5 (see http://unity3d.com/support/documentation/video/5.html) the author applies a rigidbody and a collider to a game object without losing prefab link. That's why thereafter he can make changes to the model in Studio Max which are automatically applied to the unity scene on saving. If I try doing the same, Unity asks me if I really want to lose prefab...

Apr 19 '10 at 02:52 PM drhenry
(comments are locked)
10|3000 characters needed characters left

Here is what we are doing that seems to be working well and allows the 3d model to be updated and have prefabs that use it update as welll.

Import the model make an empty game object, call it "Global" and throw a script called "Global" on it that has something like

var myModel:GameObject;

Then click on Global in the heirarchy and drag the 3d object in the project panel into the myModel var in the inspector.

Then in any script on any prefab you can instantiate the 3d object in the start function

function Start(){
var model=GameObject.Find("Global").GetComponent(Global).myModel;
var newModel=Instantiate(model,Vector3.zero,Quaternion.identity);
newModel.name="CharacterObject";
newModel.transform.parent=transform;
newModel.transform.localPosition=Vector3.zero;

}

Hope that helps

more ▼

answered Oct 08 '10 at 11:01 AM

Bill 2 gravatar image

Bill 2
164 12 12 19

sweet stuff. I love it how the script file actually holds a higher class of functions. Mooo Booo

Jul 23 '11 at 11:12 PM Lenn Dolling
(comments are locked)
10|3000 characters needed characters left

Dear lord, this workflow is abhorrent.

more ▼

answered Sep 27 '10 at 07:28 AM

Brad Newman gravatar image

Brad Newman
61 5

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

Bump as I also have to spend hours rebuilding prefabs

more ▼

answered Oct 25 '12 at 10:32 AM

sigsom gravatar image

sigsom
1

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

man do i really have to spend 3 hours doing this everytime my partner gives me an updated model? it takes over 3 hours for me to update the model if he adds for example gloves...

more ▼

answered Jun 30 '12 at 05:26 PM

gooncorp gravatar image

gooncorp
16 2 2 3

(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:

x572
x495
x224
x63
x22

asked: Apr 16 '10 at 04:17 PM

Seen: 6770 times

Last Updated: Apr 16 at 08:31 PM