5using System.Collections.Generic;
6using System.Diagnostics.CodeAnalysis;
13using Object = UnityEngine.Object;
17 public sealed partial class Asset
34 public static String[]
GetAll([NotNull] Object asset) => AssetDatabase.GetLabels(asset);
46 public static String[]
GetAll([NotNull]
Path path) => AssetDatabase.GetLabels(path.Guid);
58 public static String[]
GetAll(GUID guid) => AssetDatabase.GetLabels(guid);
70 public static void SetAll([NotNull] Object asset, [NotNull] String[] labels)
72 ThrowIf.ArgumentIsNull(asset, nameof(asset));
73 ThrowIf.ArgumentIsNull(labels, nameof(labels));
75 AssetDatabase.SetLabels(asset, labels);
88 public static void Add([NotNull] Object asset, [NotNull] String label)
90 var existingLabels =
new List<String>(
GetAll(asset));
91 existingLabels.Add(label);
92 AssetDatabase.SetLabels(asset, existingLabels.ToArray());
105 public static void Add([NotNull] Object asset, [NotNull] String[] labels)
107 var existingLabels =
new List<String>(
GetAll(asset));
108 existingLabels.AddRange(labels);
109 AssetDatabase.SetLabels(asset, existingLabels.ToArray());
122 public static void ClearAll([NotNull] Object asset) => AssetDatabase.ClearLabels(asset);
132 public static void Remove(Object asset, String label)
134 var labels =
GetAll(asset).ToList();
135 labels.Remove(label);
136 SetAll(asset, labels.ToArray());
static void Add([NotNull] Object asset, [NotNull] String[] labels)
Adds several labels to an asset's list of labels.
static String[] GetAll([NotNull] Object asset)
Returns an asset's labels.
static String[] GetAll([NotNull] Path path)
Returns an asset's labels.
static void SetAll([NotNull] Object asset, [NotNull] String[] labels)
Sets an asset's labels. Replaces any existing labels.
static void Remove(Object asset, String label)
Removes a label from an asset. Does nothing if the label doesn't exist.
static void ClearAll([NotNull] Object asset)
Clears all labels of an asset.
static void Add([NotNull] Object asset, [NotNull] String label)
Adds a single label to an asset's list of labels.
static String[] GetAll(GUID guid)
Returns an asset's labels.
Groups all asset label related static methods.
Represents a relative path to an asset file or folder, typically under 'Assets' or 'Packages'.
Replacement implementation for Unity's massive AssetDatabase class with a cleaner interface and more ...