2017.xx Tilemap

I created custom tiles, and added a prefab to the tiles. I used the GetTileData() to help make the tile, and used tileData.gameObject = perfab. The prefab has components that are set inactive at run time. When I try to build, errors come up, such as “Can’t remove RectTransform because Image (Script), LayoutElement (Script) depends on it.” However, when I wrapped the tileData.gameObject = prefab in if(!Application.isPlaying)…, I was able to build the game. Is this the right way to go about adding prefabs to a tile, and modifying them after using the palette to make a tile map? Why could I not build the game without having to use if(!Application.isPlaying)?

Figured it out - closing the tile palette window fixed the errors.