Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Any tips on making prefabs robust to updates?

Discussion in 'Prefabs' started by BlueBananaProductions, Sep 18, 2019.

  1. BlueBananaProductions

    BlueBananaProductions

    Joined:
    Sep 16, 2019
    Posts:
    5
    I recently updated from Unity 5.6 to 2019.2, and in the process many prefabs broke, particularly the components made in blender. It seems like something in the way Unity interprets the object data is different, resulting in geometries that are improperly scaled, rotated, and translated. The game still runs, but now characters will be facing the wrong directions, with body parts mis-aligned and out of proportion. I will show a picture. I changed nothing but the versions of Blender and Unity.

    Does anyone have general tips for making prefabs using blender assets with animations and materials? So that they import into Unity in predictable ways? I've tried using manual export to FBX but it isn't perfect either. I realize both of these programs are making some big changes with these recent updates, so any suggestions regarding good workflows, or best practices on modeling, animation, & materials, are encouraged!

    workflow.png
     
  2. runevision

    runevision

    Unity Technologies

    Joined:
    Nov 28, 2007
    Posts:
    1,621
    Some things to look into:

    You say you updated the version of Unity AND Blender. Does the issue happen (go from working to non-working) if you only update Unity without touching the files in updated Blender?

    When you have these broken models, does it happen only for existing instances in the scene, or does it also happen if you drag the Model Prefab into the scene, so you get a new, clean Prefab instance?
     
    BlueBananaProductions likes this.
  3. BlueBananaProductions

    BlueBananaProductions

    Joined:
    Sep 16, 2019
    Posts:
    5
    Thanks for the reply! Yes I did update both Blender and Unity. When I update only Unity (now to 2019.2.6f1) but not Blender (keeping at 2.79 rather than update to 2.8) the problem resolves... could it be an issue with the way blender exports to FBX in version 2.8?

    If I update both Blender and Unity, when I drag the model prefab into the scene the new mesh does not have the issue. So as a solution (since I'd like to keep both up to date) it seems like I can replace the model prefab for affected game objects via the prefab mode window. This may be sort of painstaking as there are several broken prefab game objects, some of which have other prefabs parented to their armature (which creates complicated hierarchies), but I think it will fix the problem.
     
  4. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    4,280
    Unity exports to FBX using Unity-BlenderToFBX.py, which is in the folder Editor/Data/Tools in the editor's install folder. That has a special path for "if Blender version is 2.8 or greater" - that probably wasn't there in Unity 5.6.

    From experience, I strongly recommend not using .blend files directly in the project. It really slows you down when editing the files. It's also prone to breaking - user settings in blender changes how fbx files are exported, so you require everyone on the team to have the same blender installed with the same user settings.
     
    Last edited: Sep 26, 2019
    BlueBananaProductions likes this.
  5. BlueBananaProductions

    BlueBananaProductions

    Joined:
    Sep 16, 2019
    Posts:
    5
    Interesting point about the Unity-BlenderToFBX.py. Thanks. As I alluded to, I did try (unsuccessfully) to resolve this problem by manual export from blender to FBX (which I assume circumvents Unity-BlenderToFBX.py). As to your recommendation, can you clarify... do you use the .blend file or the .fbx file as the model prefab in your Unity assets folder?
     
  6. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    4,280
    The .fbx file.

    When changing from .blend to .fbx, you'll have to reassign the model, though, as they won't quite give the same result (different bone names), and Unity won't recognize the two as the same model. So if your goal is to just upgrade, you need to stick with the blend files.
     
    BlueBananaProductions likes this.
  7. runevision

    runevision

    Unity Technologies

    Joined:
    Nov 28, 2007
    Posts:
    1,621
    Just to avoid misunderstandings - from what you said apart from this, I got the impression you mean recommend against using .blend files directly in the project? Might want to edit if it was a typo. :)
     
    BlueBananaProductions and Baste like this.
  8. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    4,280
    Bleh, you're right. I totally misspelled that. Yeah, @BlueBananaProductions, I recommend not using .blend files. I understand why you got confused now.
     
    BlueBananaProductions likes this.