コード例 #1
0
 private void OnDisable()
 {
     if (m_tilemapEditor)
     {
         TilemapEditor.DestroyImmediate(m_tilemapEditor);
     }
 }
コード例 #2
0
        //NOTE: m_tilemapEditor.target changes when OnSceneGUI is called, so this method makes sure to create it again if target doesn't match
        private TilemapEditor GetTilemapEditor()
        {
            var targetObj = target as TilemapGroup;

            if (!m_tilemapEditor || !m_tilemapEditor.target || m_tilemapEditor.target != targetObj.SelectedTilemap)
            {
                if (targetObj.SelectedTilemap)
                {
                    if (m_tilemapEditor)
                    {
                        TilemapEditor.DestroyImmediate(m_tilemapEditor);
                    }
                    m_tilemapEditor = TilemapEditor.CreateEditor(targetObj.SelectedTilemap) as TilemapEditor;
                }
                else
                {
                    if (m_tilemapEditor)
                    {
                        TilemapEditor.DestroyImmediate(m_tilemapEditor);
                    }
                    m_tilemapEditor = null;
                }
            }
            return(m_tilemapEditor);
        }