Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Get custom tileObject from tilemap

Discussion in '2D' started by nopogo, Feb 8, 2018.

  1. nopogo

    nopogo

    Joined:
    Sep 9, 2012
    Posts:
    25
    Let me first explain the situation. I have a scriptable tile (based on the ruletile from unity's own tile examples)

    Now I need access to that object at runtime. But all i seem to be able to get is the TileBase or Tile object (given a position) And I can't for the life of me find a way to access the linked gameObject of a specific custom tile at runtime.

    Tl;dr

    Looking for a way to retrieve the custom Tile gameObject from a given Tile.
     
  2. LiterallyJeff

    LiterallyJeff

    Joined:
    Jan 21, 2015
    Posts:
    2,807
    Maybe in your custom tile class, you can override StartUp, and keep a public reference to the instanced gameobject.

    Then when you use GetTile, and get the TileBase object or whatever, you try to cast to your custom type, and if successful you can retrieve the public gameobject reference.