Version: 2021.1
言語: 日本語
public static string[] GetLabels (Object obj);

説明

アセットのラベルをすべて取得します

using System.Linq;
using UnityEngine;
using UnityEditor;

public class AssetDatabaseExamples : MonoBehaviour { [MenuItem("AssetDatabase/Check If Labels Are Correct")] static void CheckIfLabelsAreCorrect() { for (var i = 0; i < 10; i++) { var texturePath = $"Assets/Textures/Road/Road{i}.png"; var asset = AssetDatabase.LoadMainAssetAtPath(texturePath); var labelList = AssetDatabase.GetLabels(asset); if(!labelList.Contains("Road")) Debug.LogWarning($"Road Texture \"{texturePath}\" does not contain Road label"); } } }