概要
using UnityEditor;
using UnityEngine;
public static class Example
{
[MenuItem( "Tools/Hoge" )]
private static void Hoge()
{
var path = AssetDatabase.GetAssetPath( Selection.activeObject );
var mainAssetType = AssetDatabase.GetMainAssetTypeAtPath( path );
var isFolder = AssetDatabase.IsValidFolder( path );
var isValid = mainAssetType != typeof( DefaultAsset ) || isFolder;
Debug.Log( isValid );
}
}
- MainAssetType が DefaultAsset ではない、もしくはフォルダであれば
Addressable Asset System でビルドできる
- 参考:GenerateLocationListsTask.cs の以下の処理
if (entry.MainAssetType == typeof(DefaultAsset) && !AssetDatabase.IsValidFolder(entry.AssetPath))
throw new Exception($"Cannot recognize file type for entry located at '{entry.AssetPath}'. Asset import failed or using an unsupported file type.");