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.

Feature Request Allow Preset filter for components to match game object by path in Hierarchy

Discussion in 'Editor & General Support' started by huulong, Jul 24, 2022.

  1. huulong

    huulong

    Joined:
    Jul 1, 2013
    Posts:
    206
    Currently, the Preset filter for components can only match the name of the game object the component is added to. It is not really explained on https://docs.unity3d.com/Manual/class-PresetManager.html but I understood it by watching this video:



    The matching seems to just care about finding the string, case-insensitive, without caring about word boundaries, which can be problematic. This could be improved with more advanced regex-style search, but this is not my suggestion today.

    The issues with just matching game object name are:
    1. When you care about a component automatically added to a game object created via menu (e.g. 2D Objects > Sprite > Square), you don't have the opportunity to rename the game object before component is added (e.g. it will always be "Square" + some number, but matching "Square" with filter doesn't really make sense, although you *could* exploit this to prepare a few presets for Square, Circle, etc. and map them to Environment, Character sprites preset; obviously doesn't work with other components)
    2. Game objects may have very different names but still belong to the same category. For instance, background elements. To make filter work, you'd need to prefix all such objects with "Category_" (e.g. "Background_Forest" or "BG_Forest"). This is possible but since they are already parented to my Background game object, I don't always want to do that.

    My suggestion:

    By allowing filter to match a Hierarchy path, such as Background/* or Background/** (recursive children) or Background/**/Leaf* (combine parent path and game object name), we could match complete branches of the Scene Hierarchy and use presets accordingly.

    Bonus suggestion:

    We could also have a "switcher" that changes the current default preset (per asset/component), but only locally on user's computer (no need to reorder presets in the Preset Manager, which would be seen in VCS and risks being committed and pushed). This way, the level artist, or a person temporarily taking the role of level artist, could switch all their presets to match a certain workflow/category, and keep working with it without affecting other developers.