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

Batch prefab editing tool

Discussion in 'Scripting' started by Bonfi_96, Jan 30, 2019.

  1. Bonfi_96

    Bonfi_96

    Joined:
    Oct 2, 2013
    Posts:
    34
    Hi guys, I'm updating a big project from .2 to .3 and I'm having trouble updating our prefab tools.
    We used to load them in as gameobject, edit them and set them as dirty and the changes would be relatively quickly changed.
    I tried to update our tool as suggested
    But the end result is that editing and resaving 200 prefabs takes around 25 min as each prefab is being reimported (the little window that unity uses when importing opens up once for each prefab)

    The same happens leaving our tool as it was.

    So my question is, is there a way to batch edit prefabs in a better/ faster way? We use the tool mainly to add/remove components to specific sets of prefabs
    Thanks!
     
  2. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    2,360
    Interesting solution for the previous prefab implementation, incorrect for the current.

    You should re-write a tool to instead convert those prefabs into variants. That will allow you to change one prefab variant and apply the changes altogether for all prefab subsets. Without any tools in the future by native support from Unity.

    Push them once, and remove the tool completely.

    Basically, what you were doing preivously is now a default prefab behaviour.
    So instead of doing this, you should remake your prefabs into nested prefabs / prefab variants.
     
  3. Bonfi_96

    Bonfi_96

    Joined:
    Oct 2, 2013
    Posts:
    34
    Hi, thanks for your insight.
    Wouldn't I end up in the same situation when editing the variants? If I add or remove components to a subselection of them as overrides for example. The prefabs are built in a modular fashion with components on the root and iterating through them is a must for tweaking values programmatically
     
  4. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    2,360
    When you add or remove component from a nested prefab, all prefabs containing that nested prefab will get updated. You don't need a tool to do that. If you still require to modify the prefab, simply modifying one will override the rest.
    (If overrides apply.

    Otherwise you cannot add / remove components unless prefab is unpacked which should be avoided)
     
    Bonfi_96 likes this.
unityunity