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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question automating custom collider assignement

Discussion in 'Editor & General Support' started by masterahuck, Jun 5, 2023.

  1. masterahuck

    masterahuck

    Joined:
    Sep 10, 2015
    Posts:
    72
    Hello,
    I have around 800 meshes in my project and every mesh has its own custom collider.
    If a mesh is named "tree_A" then its corresponding collider is named "collider_tree_A", is there a way to automate the assigning of colliders, doing this by hand for 800 meshes is a bit time consuming so looking for a way to automate this or streamline teh assignement process.
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    37,169
    If the names are truly that simple, prepend "collider_" to the name of the mesh and assemble the prefab.

    This is just basic editor scripting, probably using PrefabUtility and a few other bits and bobs.