コガネブログ

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

【Unity】マネージドプラグインやネイティブプラグインの設定をスクリプトから変更できる「PluginImporter」

概要

using UnityEditor;

public static class Example
{
    [MenuItem( "Tools/Hoge" )]
    private static void Hoge()
    {
        var obj = Selection.activeObject;
        var path = AssetDatabase.GetAssetPath( obj );
        var importer = AssetImporter.GetAtPath( path ) as PluginImporter;

        // Select platforms for plugin の Any Platform を変更する
        importer.SetCompatibleWithAnyPlatform( false );

        // Select platforms for plugin の Include Platforms を変更する
        importer.SetCompatibleWithEditor( true );
        importer.SetCompatibleWithPlatform( BuildTarget.iOS, true );

        // Select platforms for plugin の Exclude Platforms を変更する
        importer.SetExcludeFromAnyPlatform( BuildTarget.iOS, true );
    }
}

f:id:baba_s:20190324143245p:plain

「PluginImporter」を使用すると、
マネージドプラグインやネイティブプラグインの設定をスクリプトから変更できます

参考サイト様