Collection Tool - Unity-Technologies/com.unity.search.extensions GitHub Wiki
The Search Window is great at finding anything in Unity (Assets, GameObject, Menus, Settings...). But it can be so much more if you put just a little more time with it. It can act as a Collection Tool that can help with lots of Level Editing tasks.
Search Query Asset
Writing a good and precise query can be tedious. As an example:
Give me all meshes in current scene that have no LOD and the triangle count is larger than 2000
h: -t:LODGroup t:MeshRenderer vertices>2000
(for more Query Examples see this page)
You wouldn't want to write this EACH time you want to tweak your scene for costly mesh rendering. Enter the Search Query Workflow!
Each time you have a nice Query, save it to disk using the nifty diskette icon:
You can then double click in the Project Browser to open this query. The whole Search view state: window size, icon size, which panels were opened, table column setup (more on this below) will be preserved in the SearchQuery asset. This effectively becomes a live and dynamic collection of items.
Since the Search Window supports dragging, these live collection can act as level designer palette containing assets only relevant to some specific workflows: walls, enemies, props, etc.
Some more information on SearchQueryAsset can be found in the Manual.
Why not use folders?
If you organize all your assets in a proper folder structure, having Collection of assets might seem redundant. That said, in my humble opinion SearchQueryAsset have the following advantages on folder:
- Ease of navigation: you can put all your SearchQueryAssets in the same folder and have them readily available for all sorts of workflow instead of navigating the Project Browser to find a single asset.
- You can have multiple Search Window opened at the same time, each showing a different query/collection.
- Search Query are available through the Search Query panel. So no need to navigate folder if the Search Window is already opened (and hit Ctrl + K if it isn't).
- Collection of assets can be setup with a Search Table allowing powerful multi-editing of properties (more on this below).
- An asset can appear in multiple queries.
Think of Search Query asset as database query where the semantic of the query is more important than the location of the asset itself.
Search Query Inspector
Search Query Asset Inspector are practical in that they even host a list of items that would be yielded by a SearchQueryAsset.
This list of assets supports drag as well. The Is Search Template toggle is useful to pin a particularly useful query to the Home page of the Search Window:
Search Table View
Search Tables are a way to turn the Search Window into your own spreadsheet to allow multi-editing of objects. Setupping a proper table might take some time but SearchQueryAsset are your friend. If you save a SearchQueryAsset it will encapsulate its table configuration.
Unity already has a tool that shows objects in spreadsheet-like manner. It is the Light Explorer Tool. But it is a fairly hardcoded tool in that it only works for Lights and only shows a specfic set of editable properties:
Now you could build the same kind of tool with a simple Search Table:
But what is best is that you can now create table for any kind of objects. Imagine your game has a Weapon Scriptable object that stores all weapons statistic and icon.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu(menuName = "Gameplay/Weapon")]
public class Weapon : ScriptableObject
{
public Texture2D sprite;
public int damage;
public float range;
public float spashRange;
public float cooldown;
public float speed;
public int projectileCount;
public bool singleUse;
}
You can setup a Search Table looking like this and allowing easy tweaking of all weapon properties:
When adding a column to s Search Table you basically need to do two things:
1- Add a new columns using the Add Column + button
Notice that when you open the Column Selection tool we try to populate it with all the properties available for any objects current listed.
You can even write your own ColumnProvider which allows you to provide custom column UI and behavior.
2- When adding a column you can tweak its format which decides how the column values are displayed (or edited). Two formats allow you to easily modify column cells: SerializedProperty
and MaterialProperty
format.
When modifying a column setup, do not forget to save your search query again so it is persisted for next time!
What about other Search features?
Our Search Tour contains a lot more tips and tricks on how to get the most out of the Search Window.