Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Place a tile with SetTile without destroying the instantiated gameobject

Discussion in '2D' started by AidinD, Aug 25, 2020.

  1. AidinD


    May 3, 2017
    Is there a way to change a tile programmatically? The way I am trying to do it now is using the SetTile method which works except it destroys the GameObject the previously placed Tile instantiated.

    Example: I have a CustomTile1 which is a RuleTile and instantiates myGameObject and we have another CustomTile2 which does NOT instantiate a gameobject.

    CustomTile1 is placed in the tile editor. During runtime I click on a tile and use SetTile on the clicked tile to change it into CustomTile2. But I want to keep myGameObject. Instead it seems SetTile destroys any gameobjects previously instantiated by a tile.
  2. ChuanXin


    Unity Technologies

    Apr 7, 2015
    Sorry, I don't think this is possible right now without special scripting. To do this, you will need to script a custom Tile and override the
    method to handle the creation of the GameObject for the Tile.

    We will check out adding functionality to handle this properly.
    AidinD likes this.
  3. Mr_FJ


    Sep 4, 2013
    Hey sorry if it's not good custom to resurrect an old post, but are there any news on this, or do you have any tips on how to prevent the destruction of the old gameobject?