5using System.Diagnostics.CodeAnalysis;
6using System.Reflection;
8using Object = UnityEngine.Object;
12 public sealed partial class Asset
33#if UNITY_2022_2_OR_NEWER
34 return AssetDatabase.GetImporterType(path);
36 UnityEngine.Debug.LogWarning(
"GetImporterType not available in this Unity version - returning null");
55#if UNITY_2022_2_OR_NEWER
56 return AssetDatabase.GetImporterType(guid);
58 UnityEngine.Debug.LogWarning(
"GetImporterType not available in this Unity version - returning null");
103 public static Type[]
GetActive([NotNull] String[] paths)
105#if UNITY_2022_2_OR_NEWER
106 return AssetDatabase.GetImporterTypes(paths);
108 throw new NotSupportedException(
"GetImporterTypes not available in this Unity version");
124 public static Type[]
GetActive(ReadOnlySpan<GUID> guids)
126#if UNITY_2022_2_OR_NEWER
127 return AssetDatabase.GetImporterTypes(guids);
129 UnityEngine.Debug.LogWarning(
"GetImporterTypes not available in this Unity version - returning empty array");
145#if UNITY_2022_1_OR_NEWER
146 return AssetDatabase.GetAvailableImporters(path);
148 return AssetDatabase.GetAvailableImporterTypes(path);
175#if UNITY_2022_1_OR_NEWER
176 return AssetDatabase.GetDefaultImporter(path);
178 throw new NotSupportedException(
"GetDefaultImporter is not available in this Unity version");
205 public static Type
GetOverride([NotNull]
Path path) => AssetDatabase.GetImporterOverride(path);
233#if UNITY_2022_1_OR_NEWER
234 where T : AssetImporter
236 where T : UnityEditor.AssetImporters.ScriptedImporter
239 AssetDatabase.SetImporterOverride<T>(path);
254 public static void ClearOverride([NotNull]
Path path) => AssetDatabase.ClearImporterOverride(path);
284 [ExcludeFromCodeCoverage]
285 public static void ApplySettings([NotNull]
Path path) => AssetDatabase.WriteImportSettingsIfDirty(path);
287 internal static void SetImporterOverride([NotNull] Type value, [NotNull] String assetPath)
289 var methodName =
"SetImporterOverride";
290 var bindingFlags = BindingFlags.Public | BindingFlags.Static;
291 var methodInfo = typeof(AssetDatabase).GetMethod(methodName, bindingFlags).MakeGenericMethod(value);
292 methodInfo.Invoke(
null,
new System.Object[] { assetPath });
static GUID GetGuid([NotNull] Object asset)
Returns the GUID of an object. Returns an empty GUID if the object is null or not an asset.
Groups file related operations.
static Type GetDefault([NotNull] Path path)
Returns an asset's default importer type.
static void ApplySettings([NotNull] Path path)
Writes any unsaved changes of the given asset's importer to disk.
static Type GetActive([NotNull] Path path)
Gets the active AssetImporter type used for the given asset.
static Type GetActive([NotNull] Object asset)
Gets the active AssetImporter type used for the given asset.
static Type GetActive(GUID guid)
Gets the active AssetImporter type used for the given asset.
static Type[] GetActive(ReadOnlySpan< GUID > guids)
Gets the active AssetImporter types used for the given assets.
static Type GetDefault([NotNull] Object asset)
Returns an asset's default importer type.
static Type GetOverride([NotNull] Object asset)
Returns an asset's overridden importer type.
static Type[] GetAvailable([NotNull] Object asset)
Gets the available AssetImporter types for assets of this kind.
static Boolean IsOverridden([NotNull] Path path)
Returns true if the AssetImporter type for this asset has been overridden.
static Type[] GetActive([NotNull] String[] paths)
Gets the active AssetImporter types used for the given assets.
static void ClearOverride([NotNull] Path path)
Clears an AssetImporter override for the specified asset.
static Type GetOverride([NotNull] Path path)
Returns an asset's overridden importer type.
static Type[] GetActive([NotNull] Path[] paths)
Gets the active AssetImporter types used for the given assets.
static void SetOverride< T >([NotNull] Path path)
Sets the custom AssetImporter to use for the specified asset.
static Type[] GetAvailable([NotNull] Path path)
Gets the available AssetImporter types for assets of this kind.
Groups all AssetImporter related functionality.
static String[] ToStrings([NotNull] IEnumerable< Path > paths)
Converts an IEnumerable collection of Path instances to a string array.
static Path Get([NotNull] Object asset)
Gets the relative path of an asset.
Represents a relative path to an asset file or folder, typically under 'Assets' or 'Packages'.