Version: Unity 6.7 Alpha (6000.7)
Language : English
Import Activity window reference
Caching assets

Organize assets with labels

Labels are metadata that you can apply to assets to organize them into categories. Assets are easier to search and filter with a label applied to them. You can assign more than one label to each asset, and you can make custom labels or use Unity’s predefined labels.

Labels have the following advantages:

  • If you use version control, labels are shared across the team. The labels stay attached to the asset even if you move or rename it.
  • They’re lightweight, project-level metadata that you can query without loading the asset file from disk, so custom tooling and scripts can check many assets without deserializing them.
  • Labels set from scripts are immediately available in the Editor, and are shared with the Search and Project windows, so you can quickly find what you need.

Labels are an Editor-only way of organizing assets. To organize GameObjects during runtime, use tags. For more information about how to use tags with GameObjects, refer to Assign tags to GameObjects.

Add a label to an asset

To add a label to an asset:

  1. Open the asset in the Inspector window.

  2. If the Preview panel is minimized, drag the title bar (A) up to expand it.

  3. In the Preview panel, select the label icon (B) to access the labels menu.

    The Preview panel in the Inspector window. A: The title bar. B: The label icon
    The Preview panel in the Inspector window. A: The title bar. B: The label icon
  4. In the labels menu, select a label to apply it. The menu lists every label in the project. The check mark next to the label name indicates that the label is applied to the asset.

Create a new label for an asset

To create a new label for an asset:

  1. Type the label name in the labels menu text box.
  2. Press Space or Enter to save the label.

You can then toggle the new label like any other entry in the menu.

Remove a label from an asset

To remove a label from an asset:

  1. Open the labels menu.
  2. Select the label you want to remove to clear the check mark.

Filter assets by label

You can filter assets with labels in the Search window, the Project window or in the Inspector with the Advanced Object Picker window.

To filter assets in any of the windows, use the l: token in the search bar to find assets with the specified label. For more information about textual searches, refer to Search expressions.

For the Search window, you can also select labels with the Visual query builder.

Search by label in the Project window

  1. In the Project window, select the label icon (Search by Label).

  2. From the list, select a label name.

    Search by label in the Project window
    Search by label in the Project window

The Project window shows results grouped by location: All, In Packages, In Assets, and under the folder you currently have selected. For more information about how to search in the Project window, refer to Search assets with the Project search provider.

Manage asset labels from scripts

You can perform operations on multiple labels at a time with scripts:

You can also filter your search by label with AssetDatabase.FindAssets or with AssetDatabase.FindAssetGUIDs.

For example, the following code retrieves all GameObject assets with the same label named Vegetation and displays the paths to the assets:

using UnityEditor;
using UnityEngine;

static class VegetationReport
{
    [MenuItem("Tools/List Vegetation Prefabs")]
    static void ListVegetationPrefabs()
    {
        // The l: token matches assets by label. Combine it with t: to
        // narrow the results to a single asset type.
        string[] guids =
            AssetDatabase.FindAssets("l:Vegetation t:GameObject");

        foreach (string guid in guids)
        {
            Debug.Log(AssetDatabase.GUIDToAssetPath(guid));
        }
    }
}

Additional resources

Import Activity window reference
Caching assets