Version: 2023.2
言語: 日本語
public static Type[] GetImporterTypes (ReadOnlySpan<GUID> guids);

パラメーター

guids Array of asset GUIDs to check. The importer type for each asset in the array is returned.

説明

Returns the types of importers associated with the specified array of assets, without loading those assets.

This method is a batch version of AssetDatabase.GetImporterType. Use this method if you need to check a large number of asset importers at once. Note: GUID Arrays can be implicitly cast to ReadOnlySpan, see example for usage.

using UnityEngine;
using UnityEditor;

public class AssetDatabaseExamples { [MenuItem("AssetDatabase/GetMatchingAssetTypes")] public static void GetMatchingAssetTypes() { var matchingAssets = AssetDatabase.FindAssets("Powerup"); GUID[] guids = new GUID[matchingAssets.Length];

for(int i = 0; i < guids.Length; ++i) { guids[i] = new GUID(matchingAssets[i]); }

var matchingTypes = AssetDatabase.GetImporterTypes(guids);

foreach (var curType in matchingTypes) { Debug.Log($"Importer type: {curType}"); } } }

public static Type[] GetImporterTypes (string[] paths);

パラメーター

paths Array of asset paths to check. The importer type for each asset in the array is returned.

説明

Returns the types of importers associated with the specified array of assets, without loading those assets.

The asset paths you provide should be relative to the project folder root. For example, "Assets/MyTextures/hello.png". This method is a batch version of AssetDatabase.GetImporterType. Use this method if you need to check a large number of asset importers at once.

using UnityEngine;
using UnityEditor;

public class AssetDatabaseExamples { [MenuItem("AssetDatabase/GetImporterTypeOfSelectedObjects")] public static void GetImporterTypeOfSelectedObjects() { var selectedObjects = Selection.objects; string[] paths = new string[selectedObjects.Length];

for (int i = 0; i < paths.Length; ++i) { paths[i] = AssetDatabase.GetAssetPath(selectedObjects[i]); }

var selectedObjectTypes = AssetDatabase.GetImporterTypes(paths);

foreach (var curType in selectedObjectTypes) { Debug.Log($"Importer type: {curType}"); } } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961