Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Workflow questions (prefab problems, etc)

Discussion in 'External Tools' started by dock, Aug 28, 2008.

  1. dock

    dock

    Joined:
    Jan 2, 2008
    Posts:
    405
    I seem to be having some serious workflow problems with Unity.

    My objects are breaking their prefabs whenever I add physics and scripts to them, and they refuse to convert back into a prefab afterwards. This means that my levels are currently not using any prefabs, and in general they're pretty messy to work with. when I change anything I have to rebuild it all.

    Also, this breaking prohibits me from editing their original models in MAX and re-exporting.

    Is there any recommended solution for how to import models and add scripts without breaking the original prefab? Is it possible to assign some of the objects within a model to be colliders and others not to be?

    The "GameObject -> Upload Changes to Prefab" doesn't seem to work for me most of the time. Is there any documentation to suggest when this does and doesn't work? What does it take to break it?
     
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,250
    I suspect that the "prefabs" you're using are just the mesh files. You want to create actual prefabs, using Create -> Prefab. I've never seen a case where applying changes to a real prefab wouldn't work.

    --Eric
     
  3. dock

    dock

    Joined:
    Jan 2, 2008
    Posts:
    405
    Oh, really? I thought that when I dragged meshes into the scene that they were prefabs by default. Their object name is blue rather than black for starters.

    *tries it*

    Oh yeah, that seems to work... That makes a big difference! :) Thanks!

    If I re-export the FBX file, will my prefab be updated with the changes?
     
  4. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,250
    Yep.

    --Eric
     
  5. ProtonOne

    ProtonOne

    Joined:
    Mar 8, 2008
    Posts:
    406
    The problem I have is that only some changes are propagated to your prefab.

    If you add any meshes/groups to the fbx, or move the position/rotation of and meshes/groups that will not be updated.

    Then you need to recreate the prefab from scratch. There is also some way of manually creating the missing pieces, but I haven't gotten that to work. If I could figure it out, an editor script could probably solve this problem.

    I end up creating an empty GameObject and putting the model as a child of that. Then all scripts/compound colliders/particle effects/etc. go on the empty parent instead of the model.

    One trick I have used (in cases where I really don't want to recreate the prefab) is to keep an inactive object in my scene without making it a prefab, but I treat it like a prefab and assign it to scripts to be Instantiated. Then the model retains its prefab connection to the fbx file. Doesn't work across scenes though.
     
  6. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,250
    They should be (they always are here). Make sure you are creating "real" prefabs as described above.

    --Eric
     
  7. ProtonOne

    ProtonOne

    Joined:
    Mar 8, 2008
    Posts:
    406
    I just tried the following:

    1. Created 2 spheres in Maya
    2. Exported to FBX as Spheres.fbx
    3. Imported into Unity
    4. Dragged Spheres model into the scene (it now appears as a 'fake' prefab)
    5. In project view clicked "Create"->"Prefab"
    6. Named the prefab "SpheresPrefab" (it appears as an empty box)
    7. Dragged the spheres 'fake' prefab from the scene hierarchy onto the empty "SpheresPrefab" in the project hierarchy.
    8. Now I have a 'real' prefab that is just a model of 2 spheres.
    9. Go back to Maya, add a 3rd sphere.
    10. Save the scene over top of the existing Spheres.fbx in my project
    11. Unity loads for a few seconds as it reimports the model.
    12. Spheres prefab in the scene still only has 2 spheres.
    13. Drag a new "SpheresPrefab" into the scene, still only 2 spheres.
    14. Drag the "Spheres" fbx 'fake' prefab into the scene. It does have all 3 spheres.

    Same thing when I translate the spheres away from eachother.

    I think the 'real' prefab just becomes a collection of meshrenderers, with no connection to the fbx 'fake' prefab anymore.

    Hmm... what if I delete a sphere only leaving one...

    Okay, just tried it. The 'real' prefab still has two child objects for the 2 spheres, but 1 of them has a problem with its Mesh Filter: "Missing (Mesh)".

    I've seen some other threads discussing this issue, but people seem to accept that it is okay. I am quite surprised that more people don't find this to be a problem. I mean, it isn't a huge problem, but still a problem.

    Just found the main thread I was thinking of:
    http://forum.unity3d.com/viewtopic....sc&highlight=prefab+connection+break&start=15
    It would be awesome if I am just misunderstanding this.
     
  8. holmeren

    holmeren

    Joined:
    Dec 12, 2006
    Posts:
    300
    I dont see it as a big problem but just that you have to think your modelling and prefabs all the way through before you go make your Final prefab an place 1000 of your prefabs.

    I like to note that I like to start the prefab with a empty gameobject. I try to get my coders to write scripts that I can apply to an empty gameobject (script will call to naming of my mesh) Then I dont have to apply scripts over and over again and I feel I have a better flexiblity with the prefab (rotation/position) like a more links on a chain. If I add extra geometry to the prefab (toplights on a car that was not in the early design) I make a new empty game object make that a child of the first empty gameobject and then drag my toplights fbx into that. If I need scripts on those light I by doing so dont brake my prefab I just add to it.
    By doing so I actually think that you will solve your "3 sphere" issue....

    I just feel confident in this way I dont know if its helpless stupid ;)


    -my 50 Cs

    Cheers
     
unityunity