ソースコード
using UnityEditor; using UnityEditor.SceneManagement; using UnityEngine; using UnityEngine.Tilemaps; [CustomEditor( typeof( Tilemap ) )] public sealed class TilemapEditor : Editor { public override void OnInspectorGUI() { base.OnInspectorGUI(); var tilemap = target as Tilemap; if ( GUILayout.Button( "Compress Bounds" ) ) { Undo.RecordObject( tilemap, "Compress Bounds" ); tilemap.CompressBounds(); EditorSceneManager.MarkSceneDirty( tilemap.gameObject.scene ); } } }
使用例
Tilemap の Inspector に追加された「Compress Bounds」ボタンを押すと
Tilemap の origin と size を最適化できます