5using System.Collections.Generic;
6using System.Diagnostics.CodeAnalysis;
9using Object = UnityEngine.Object;
13 public sealed partial class Asset
30 public static String[]
GetAll([NotNull] Object asset) => AssetDatabase.GetLabels(asset);
42 public static String[]
GetAll([NotNull]
Path path) => AssetDatabase.GetLabels(path.Guid);
54 public static String[]
GetAll(GUID guid) => AssetDatabase.GetLabels(guid);
66 public static void SetAll([NotNull] Object asset, [NotNull] String[] labels)
68 ThrowIf.ArgumentIsNull(asset, nameof(asset));
69 ThrowIf.ArgumentIsNull(labels, nameof(labels));
71 AssetDatabase.SetLabels(asset, labels);
84 public static void Add([NotNull] Object asset, [NotNull] String label)
86 var existingLabels =
new List<String>(
GetAll(asset));
87 existingLabels.Add(label);
88 AssetDatabase.SetLabels(asset, existingLabels.ToArray());
101 public static void Add([NotNull] Object asset, [NotNull] String[] labels)
103 var existingLabels =
new List<String>(
GetAll(asset));
104 existingLabels.AddRange(labels);
105 AssetDatabase.SetLabels(asset, existingLabels.ToArray());
118 public static void ClearAll([NotNull] Object asset) => AssetDatabase.ClearLabels(asset);
128 public static void Remove(Object asset, String label)
130 var labels =
GetAll(asset).ToList();
131 labels.Remove(label);
132 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'.