Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Prefab Updater - Synchronizes 3D model based prefabs for 3D model changes

Discussion in 'Assets and Asset Store' started by mkgame, Sep 3, 2016.

  1. mkgame

    mkgame

    Joined:
    Feb 24, 2014
    Posts:
    592
    One click model based prefab updater for mesh and bones.

    The Prefab Updater is an editor extension. I waited, waited and waited, but nobody made a convenient prefab updater tool, so I had to do this job, because my game developing phase needs prefabs now. It was pretty complicated, but I have good knowledge in model transformation, in diff tools and I also wrote a commercial XML Tool, that has a high complexity in model transformations.

    Every indie game developer knows the problem, that changing a model makes the model based prefab asynchron to the changes. Complex configured components can reference e.g. at a tank controller 18 wheels, 2 tracks, 18 wheel collider, turrets, guns. Copying components to the new model instance requires re-referencing these game objects again, and if the prefab itself has been referenced, then it must be referenced again. On skeleton/bone based models we often drop components, e.g. particle effects, collider, scripts on bones, that we dont want to lose. Prefab Updater handles this too, also rebuilds the whole skeleton for the skinned mesh renderer.

    Additionally you can switch your model references between .fbx, .blend and .dae 3D models.I needed this feature too and I additionally provide you with this feature. You must have the models already, with the same name in the same directory.
     
    Last edited: Sep 9, 2016
    EiknarF and theANMATOR2b like this.
  2. mkgame

    mkgame

    Joined:
    Feb 24, 2014
    Posts:
    592
    MeshFilter/MeshRenderer


    SkinnedMeshRenderer (Skeleton/Bones)
     
  3. mkgame

    mkgame

    Joined:
    Feb 24, 2014
    Posts:
    592
    In the skinned mesh renderer video you can see a non updated bounding box on the instantiated prefab, this has been already fixed.
     
  4. mkgame

    mkgame

    Joined:
    Feb 24, 2014
    Posts:
    592
  5. mkgame

    mkgame

    Joined:
    Feb 24, 2014
    Posts:
    592
    If there are any issues, then please post it in this thread. The fixes are mostly fast, but Unity approval not ;).
     
  6. eSculpt

    eSculpt

    Joined:
    Oct 7, 2016
    Posts:
    3
    Hey mkgame

    Nice extension, but it would be really great to have an option to update prefab and assign materials that are in the prefab based on mesh name, even if the hierarchy changes.

    This is what I was hoping to use the extension for, and unfortunately it can't do this.
     
  7. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,238
    We made some changes to animated models, but prefabs in the game didn't update automatically. Very frustrating...until we found this tool. Quick and easy to use, works great! Thank you! Saved us a bunch of time rebuilding prefabs.
     
    mkgame likes this.
  8. mkgame

    mkgame

    Joined:
    Feb 24, 2014
    Posts:
    592
    Thank you for the positive comments!
     
  9. mkgame

    mkgame

    Joined:
    Feb 24, 2014
    Posts:
    592
    1.) Texture Update?
    I also wrote a script for updating SubstancePainter created textures to the 3D model materials (standard metalic). The texture name contains 3 parts, e.g.: ABuilding1_Building_Normal ( [model name]_[mesh object name]_[texture_type] ).This asset does not contain that script and it has some Unity updating problems. The materials are not updating correctly, I have to select each material to actualize the textures on them. For me it is not a problem, clicking the down cursor in the material folder and it is done in one sec, but I would blame myself providing this.

    2.) Material Update?
    If you really want to update the materials, just the materials, then do the following. Unity creates the materials, if you import the 3D model. If you changed the material names (and you want to update them), then remove all materials regarding to the 3D model and right click on the 3D model and select reimport. All the materials for all the meshes will be created in the Material folder, relative to the 3D model folder. All the materials will lost their textures!

    I belive this could be your problem.

    If point 2. is not the problem, then please explain your problem more detailed. Thank you in advance!
     
    Last edited: Oct 7, 2016
  10. eSculpt

    eSculpt

    Joined:
    Oct 7, 2016
    Posts:
    3
    Hey @mkgame

    Apologies for the vague description of the problem.

    I'll illustrate properly below.

    In image 1 I create a few cubes in maya under a group and export as fbx

    01.jpg

    I then in unity apply 3 different materials and save out the prefab

    02.jpg

    Then in maya again I change the hierarchy of the objects without changing the names of the meshes

    03.jpg

    I then use the UpdatePrefab(manual apply required) script, and the material allocations per mesh don't stick
    (also in this test an additional copy of pCube1 seems to have been created, but that's not related to what I'm showing here.)

    04.jpg
     
    mkgame likes this.
  11. mkgame

    mkgame

    Joined:
    Feb 24, 2014
    Posts:
    592
    Thank you for this well made explanation. I understand your problem. Maya creates materials, which are then in the Material folder, relative to the 3D model file. I use these materials to update the prefab, because they ment to be for the meshes. If the materials change, I update them for the meshes in the prefab. You want to keep the materials, which are defined in the prefab.

    I'm not sure you really want this. The standard approach is, create a mesh, paint the textures (For indie developer I found just the Substance Painter, excellent tool, even if you are not good in texture painting you get fast results and good results.). Substance Painter allows you to paint the materials, which are assigned in your 3D tool (in your case Maya) to the faces/meshes, and it produces the textures (Albedo, AO, normal, metallic and more). I recommend to save the textures in a sibling folder to the Material folder, in the Textures folder. I wrote an editor script for my shader (also for metalic) and map the textures to the material by one click (not included in this asset), by name. Then you can change in this tool chain the mesh, the material, textures and the Prefab Updater keeps the prefabs synchron. This incredible boost your development speed and brings good results!

    However, I will build a switch for this, new menu entry, something like: Update, but keep assigned materials. It can make sense if you want to share materials in different meshes, which are not uwrapped (without mesh faces/texture mapping). Maybe, this then for very old mobile devices.

    The last picture shows a bug.
     
    Last edited: Oct 21, 2016
    eSculpt likes this.
  12. mkgame

    mkgame

    Joined:
    Feb 24, 2014
    Posts:
    592
    @eSculpt Thank you for this simple example, it also showed me a major bug.

    New release uploaded. I created a new example in the scene for updating the prefabs without changing the materials. More important is a bugfix in the recursive functions (After hierarchy movements the mapping could stop, so keep an eye on it!). Also added better support for mesh based root nodes, but I recommend you to do not have mesh references in root nodes (In 3D models and in prefabs).

    It is in approval state and Unity is quite fast, if it is not a new asset.
     
    eSculpt likes this.
  13. eSculpt

    eSculpt

    Joined:
    Oct 7, 2016
    Posts:
    3
    @mkgame

    Hay no problem man.

    Thanks for taking a look.
    Looking forward to testing your update :)
     
    mkgame likes this.
  14. mkgame

    mkgame

    Joined:
    Feb 24, 2014
    Posts:
    592
    But hey, you got the version for 10$ ;), it will rise to 30$ +-5$ soon.

    New version is available!
     
  15. mkgame

    mkgame

    Joined:
    Feb 24, 2014
    Posts:
    592
    Next release is on the way. Multiple prefab processing by multiple prefab selection will be available in the next release.

    The price will rise to 25$.
     
    Last edited: Jan 31, 2017
  16. mkgame

    mkgame

    Joined:
    Feb 24, 2014
    Posts:
    592
    There is a bug, if you remove a skinned mesh renderer (bone based mesh) in your 3D tool and then you try to update the prefab. I just renamed the skinned mesh renderer component and then I got an exception.

    The fix is already made and will be uploaded after testing it for regressions.
     
  17. mkgame

    mkgame

    Joined:
    Feb 24, 2014
    Posts:
    592
    There is also another bug, where linked objects (In Blender you can link object materials, texture maps, meshes with Ctrl + l.) are not correctly updated. This happens because I synchronize with the mesh reference, but in this case more objects have the same mesh refernece. I check now for linked objects and map them if the mesh and the name (else not possible) is the same. If it is not a linked object, then the regular mesh reference mapping will be done.

    But maybe these are not bugs, but improvements. I name it bugs, because my expectation was that it works fine in all circumstances. It works fine now and I hope I will not found more issues.
     
  18. mkgame

    mkgame

    Joined:
    Feb 24, 2014
    Posts:
    592
    The new version is in Unity approval.

    - Added 2 new scripts for texture mapping. Supported workflows are Substance Painter exported textures to Unity metallic standard shader and alloy standard shader. Color map, metallic, normal map and emission textures are mapped. For your own workflow you can modify the scripts (not a big deal) or name the textures as Substance Painter it does.

    - Bug fixes in comment #16 and #17
     
  19. mkgame

    mkgame

    Joined:
    Feb 24, 2014
    Posts:
    592
    There is an issue with updating the position/rotation/scale on the bone parrent. Hard to have this issue.
    As simple workaround set these values by hand.

    LeftTrackArmature <- This is the parent of the bones, there you have to adapt the pos/rot/scale.
    • bone1
    • bone2
    • bone3

    I'm really making a game, so I have to work a lot with Blender, and I have also iterate (that's the reason for this editor extension) frequently over my 3D object. http://www.metadesc.com/studio/

    Enjoy the time you got for using this asset!
     
  20. EiknarF

    EiknarF

    Joined:
    Apr 28, 2011
    Posts:
    139
    I have a lot of assets with multiple meshes in the source which I manually pick and create prefabs from.

    I would like to use your updater tool to update the prefabs when I change hierarchy of the rig, but at the moment it adds all the meshes from the source asset into all the prefabs, it would be great to have an option to not add new skinned mesh renderers to the prefab.

    An example of this is

    rat.fbx
    ->rig
    ->rat_king_mesh
    ->rat_mesh
    ->rat_mutant_mesh
    ->rat_lava_mesh

    and then from this I would make;

    rat_king.prefab
    ->rig
    ->rat_king

    rat.prefab
    ->rig
    ->rat_mesh

    rat_mutant.prefab
    ->rig
    ->rat_mutant_mesh

    Thank you.

    edit:
    it also changes my material which I don't want as I manually assign them.

    I have a whole folder of 150+ monsters and NPCs broken from the latest unity update I was hoping to fix with one click.
     
    Last edited: Aug 28, 2017
  21. Quatum1000

    Quatum1000

    Joined:
    Oct 5, 2014
    Posts:
    888
    Hi,
    unfortunately the guy does not reply. I'm also interesting in this asset.

    I think the problem is, how the Updater will know what meshes have to be updated or not?

    Would be possible with an option/menu entry of PrefabUpdater
    >Update Existing Meshes Only
    >Update Existing and New Meshes
    >Update Existing and Delete None Existent.

    There are a lot of combinations possible.

    Anther solution would be to add a script/subclass or enum property to each prefab that defines what the PrefabUpdater should do.

    public PrefabUpdaterProperty prefabUpdaterProperty = PrefabUpdaterPropertySetting.Update ExistingMeshesOnly; // or whatever..
     
    Last edited: Jan 4, 2018
  22. mkgame

    mkgame

    Joined:
    Feb 24, 2014
    Posts:
    592
    Hi,

    sorry for this late response, somehow I got no e-mail for your post... Next time, if I not answer here, please send an e-mail. Not sure you already did it and that I already added the features, that I will describe.

    There are limitations for 3D model/prefab synchronization. I described it in the asset description, that multiple 3D models can just partially updated (position, rotation and scale). I could not synchronize more automatically. The best way is to put together your 3D models in the 3D editor, not in Unity. Generally, I couldn't use the prefabs in Unity because the 3D models were not updated in the prefab. With this tool you can use them at least, if you follow the pre-conditions.

    However, there are options with the text "multimodel supported", that you can apply for your prefabs. There are also "No material changes" options to do not update the textures/materials, but this works properly for prefabs with a single mesh.
     
  23. mkgame

    mkgame

    Joined:
    Feb 24, 2014
    Posts:
    592
    Hi,

    the trouble is, that with a full synchronization doing wrong things cannot be avoided with multiple mesh references. To clarify, if you have just one mesh reference with multiple meshes in it (e.g. FBX file with more separated meshes), then it works fine. So, try to use your 3D editor to build your fully 3D model. At the time you can update position/scale/rotation for multiple meshes, that is still helpful. The things you must do are, remove/add mesh components manually. If you are done with that, then you can update the position/rotation/scale for all the added meshes and old meshes.
     
  24. mkgame

    mkgame

    Joined:
    Feb 24, 2014
    Posts:
    592
    Actualized for Unity 2017 and 2018 and also for Unity 5.6.6f2.
     
  25. Quatum1000

    Quatum1000

    Joined:
    Oct 5, 2014
    Posts:
    888
    Thanks for the Update!

    Did you know about the curious issue from unity when import an FBX with a single mesh?
    The mesh is rotated 90° on x-axis to it's original. When import 2 meshes (inside of the FBX) then the rotation is correct.

    Did you know about a script that rotates vertexes from a mesh around a pivot position?
    Thank you.
     
  26. mkgame

    mkgame

    Joined:
    Feb 24, 2014
    Posts:
    592
    For Blender? This depends on the 3d editor.
     
  27. Quatum1000

    Quatum1000

    Joined:
    Oct 5, 2014
    Posts:
    888
    When importing fbx2013 from 3ds max or Blender into Unity anyway. This is an generally problem. The curl thing is, the fbx does not include the original pivot.
     
  28. mkgame

    mkgame

    Joined:
    Feb 24, 2014
    Posts:
    592
    I work with Blender and I don't have pivot issues, but the 90 degree rotation is a known issue. For Blender you can download a python script, search for "Blender fix rotation for Unity", or fix it manually: select all the objects in the scene, rotate 90 degree all the objects, then apply rotation, then turn all the objects back but do not apply. Thats all for the rotation issue regarding to Blender, but this must be done each time before you save your Blender project. However, I'm not sure that somewhat is different for a single object.
    Is the pivot point incorrect, because it is rotated? If not, then maybe you have a script in your project, that cause the incorrect position for the pivot point.
     
  29. Quatum1000

    Quatum1000

    Joined:
    Oct 5, 2014
    Posts:
    888
    Thank you.
    I don't work with blender, only 3dsmax. And I use the pure mesh from the asset database. So I require a script that rotated the mesh vertices round the X axis.
     
  30. mkgame

    mkgame

    Joined:
    Feb 24, 2014
    Posts:
    592
    This asset will not work fully under 2018.3. The issue is, that in 2018.3 the prefab handling has been changed and with these changes it is not anymore allowed to change the prefab in the way I do. In the next update this will be fixed.
     
    Last edited: Dec 31, 2018
  31. mkgame

    mkgame

    Joined:
    Feb 24, 2014
    Posts:
    592
    Not sure that I'am able to fix this issue for 2018.3. It seems to be, that 2019.1a9 fixes this issue: https://forum.unity.com/threads/des...side-a-prefab-instance-is-not-allowed.555868/

    If you use it in 2018.3 the GameObjects in prefabs cannot be removed.

    Workaround: The logs shows what couldn't be removed, and you have to remove it manually and remove the instantiated helper prefab instances. Then try to update the prefab again and when it fails again, then repeat the procedure.

    I cannot do much at this point, because for the synchronization it is necessary, that GameObjects are removed. I cannot even collect a list of GameObjects, which must be removed, because the synchronization can fail, due to the non removed GameObjects.
     
    Last edited: Dec 31, 2018
  32. mkgame

    mkgame

    Joined:
    Feb 24, 2014
    Posts:
    592
    I found a solution for the new prefab system. The prefabs will be unpacked, so they can then be changed. Just the root prefab will be unpacked. In this way the children prefabs should be preserved. Theoretically this allows now to update nested 3D models, by keeping in each of the nested prefabs one 3D model.

    The result of the recommended updating option is not anymore a modified prefab instance, due to the unpack procedure. However, Unity provides replacing a prefab by holding the alt key and drag & drop the result to the prefab in the project. This may change in the future, depends on how Unity improves the PrefabUtility functions. Unfortunately the Unity support forum does not work well for me, so I cannot influence further changes, but I still try it. Unity team made a lot in 2018.3, they have to 'polish' the features urgently.

    Directly updating the prefab, without creating a clone prefab instance, works fine.

    This will be released as fast as possible, after testing it with nested prefabs.
     
    Last edited: Jan 4, 2019
  33. mkgame

    mkgame

    Joined:
    Feb 24, 2014
    Posts:
    592
    The non released previous PrefabUpdater version for 2018.3 and higher resets all the prefab instances to the replaced prefab coordinates. This has been fixed. The recommended prefab update, that created a modified prefab instance, which then could be applied, is not anymore available, due to the changes in Unity 2018.3. However, instead of recommended you have an option [TEST], which creates a non linked updated prefab instance, that can be checked for correctness. Then if you satisfied with the result, you can run the "Update Prefab" option, which then applies the changes to the prefab. You can also run "Update Prefab" without a test.
    I'am testing the new version, if there are no more errors, then I will upload. You can have a pre-version, if you urgently need this tool for Unity 2018.3,
     
    Last edited: Jan 21, 2019
  34. Lewnatic

    Lewnatic

    Joined:
    Sep 29, 2012
    Posts:
    209
    Hello @mkgame

    I purchased your asset. Sadly i read in your thread that there are issues with Unity 2018.3.
    I am indeed running that unity version and the prefabs are not updated properly after i replaced the imported fbx file.

    I am using an updated rig that has more bones then the version before. Also i have scripts added to the bones of the rig. So my hope was that all bones are updated correctly with the scripts still attached to the bones.

    Can you confirm that this is fixed with unity 2019.1?
     
  35. mkgame

    mkgame

    Joined:
    Feb 24, 2014
    Posts:
    592
    Hello @Lewnatic,

    won't be better with 2019.1. I already have an updated version, because I also use Unity 2018.3.x for the hierarchical prefab feature. Should also work in 2019.1. I just wanted to test it in my project until someone is requesting for the new version. I will upload it today, but not sure how long Unity needs for approval. If you need it faster, I can send you the changed files, that must be replaced in the asset.
     
  36. mkgame

    mkgame

    Joined:
    Feb 24, 2014
    Posts:
    592
    New version is in Unity approval. This new version must be used for Unity 2018.3 and higher versions, but not for lower versions! However, older Unity versions are also supported. The new version is 1.5, it works slightly different, due to the new Unity API around the prefabs. It is just a compatibility update.
     
  37. Jakub_Machowski

    Jakub_Machowski

    Joined:
    Mar 19, 2013
    Posts:
    635
    Hello There is bug in Your asset :) change Position scale rotation dont work, also it isnt updated when using update prefab, I change eyes of my character in fbx (names are exactly the same) Your system ignore it and change mesh but not position rotation to new one. Could You please fix it? I'm workin on 2018.4
     
  38. supneo

    supneo

    Joined:
    Jul 29, 2012
    Posts:
    32
    nothing works in version 2022.1.3f1

    I recommend that you edit what it says in the store as it is not supported on higher versions as specified.