コガネブログ

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

【Unity】シリアライズされたシングルトンなアセットの参照をエディタ拡張で取得できる「Unsupported.GetSerializedAssetInterfaceSingleton」

概要

using UnityEditor;
using UnityEngine;

public class Example
{
    [MenuItem( "Tools/Hoge" )]
    private static void Hoge()
    {
        var playerSettings = Unsupported.GetSerializedAssetInterfaceSingleton( "PlayerSettings" ) as PlayerSettings;

        Debug.Log( playerSettings );
    }
}

Unsupported.GetSerializedAssetInterfaceSingleton を使用すると
PlayerSettings のようなシングルトンなアセットの参照を取得できます