概要
using System.Reflection; using UnityEditor; public class Example { [MenuItem( "Tools/Hoge" )] private static void Hoge() { var assembly = typeof( AssetDatabase ).Assembly; var type = assembly.GetType( "UnityEditor.GridPaintingState" ); var property = type.GetProperty( "scenePaintTarget", BindingFlags.Public | BindingFlags.Static ); // 第2引数で Active Tilemap に設定したいゲームオブジェクトを指定する property.SetValue( type, Selection.activeGameObject ); } }
上記のようなコードを記述することで
Tile Palette の Active Tilemap をスクリプトから変更できます