コガネブログ

平日更新を目標に Unity や C#、Visual Studio、ReSharper などのゲーム開発アレコレを書いていきます

【Unity】Addressables で各グループの BundledAssetGroupSchema の Build Path や Load Path の名前を取得するサンプル

ソースコード

using System.Linq;
using UnityEditor;
using UnityEditor.AddressableAssets;
using UnityEditor.AddressableAssets.Settings.GroupSchemas;
using UnityEngine;

public static class Example
{
    [MenuItem( "Tools/Hoge" )]
    public static void Hoge()
    {
        var settings = AddressableAssetSettingsDefaultObject.Settings;

        var names = settings.groups
                .Select( x => x.GetSchema<BundledAssetGroupSchema>() )
                .Where( x => x != null )
                .Select( x => x.BuildPath.GetName( settings ) )
            ;

        foreach ( var name in names )
        {
            // 以下のような名前を取得できる
            // LocalBuildPath
            // RemoteBuildPath
            Debug.Log( name );
        }
    }
}