0
\$\begingroup\$

I have several objects/Models/FBX that contain different childrens and it attached several mono-behavior scripts with different values assigned publicly in the inspector (settings). SO of the assignments are manually drag-and-drop in the inspector.

Now the problem is each time we update the model in the project (FBX in the project) we have to drag and drop the model/FBX again in the hirarchy. It means that we have to attach all the scripts again with the values/Data (that we assigned in the inspector) again.

I am currently looking for the right way to do this job. Currently, I place both new and old Models in the scene and then one by one I copy-paste the old object's script component into the new objects by viewing every child of an object. Then, I delete the old one model from the hirarchy. It is a very time consuming process. I want to automate it. Just like Unity I should save all the information (Components and assignment) of a game-object in a separate file (meta file custom) and bring them again on button click. But its challenging as i dont know how to save assignments (refrence objects).

Note: I have to bring the fbx again in hierarchy because sometimes the object not properly update in the scene. Like mesh gets rotate or scaled in weird manner. Or sometime FBX childs are removed or add.

\$\endgroup\$
  • \$\begingroup\$ Can you give us a bit of context about what this FBX and the various entities within it represent in your game world? \$\endgroup\$ – DMGregory Nov 18 '19 at 18:03
  • \$\begingroup\$ It is an fbx of a train which contains different doors, windows, hull, seats, and boggies \$\endgroup\$ – Muhammad Faizan Khan Nov 18 '19 at 19:12
  • \$\begingroup\$ And what are the specific symptoms of "sometimes the object does not properly update in the scene"? \$\endgroup\$ – DMGregory Nov 19 '19 at 11:20
  • \$\begingroup\$ Like if i rotated a door in max and bring it in unity. or sometime mesh get scaled in weird manner. \$\endgroup\$ – Muhammad Faizan Khan Nov 19 '19 at 11:59
  • \$\begingroup\$ Sometime updated changes are not reflect in hierarchy and we have to bring again the fbx in hierarchy. \$\endgroup\$ – Muhammad Faizan Khan Nov 19 '19 at 12:00
0
\$\begingroup\$

When creating 3D model you have to take care about naming convention which is very important. Object hierarchy should have proper name and position. In your case there is a 3D model of Train and it has two doors and four windows:

M_Train (M = Model/Mesh, Train = name /reference)

  • R_Front_Door (R = Right)
  • L_Back_Door (L = Left)

  • R_Front_Window

  • L_Front_Window
  • R_Back_Window
  • L_Back_Window

It is really upto you how you want to name your gameobjects.

Other thing is use only one script and attach it to the parent gameobject. Then attach child objects by finding their names in the parent object to appropriate variable in the script. You can use GameObject.Find to find object.

If your 3D modeling tool scale is according to Unity's then it won't scale or rotate or transform. It will always be same as in your 3D modeling tool. See this useful link of how to import from 3D modeling tool.

| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.