Search Unity

How do you make rule tiles interactive?

Discussion in '2D' started by cwells1298, Jul 16, 2018.

  1. cwells1298

    cwells1298

    Joined:
    Jan 17, 2017
    Posts:
    5
    So, I've recently discovered the tilemap feature in Unity and started playing around with it. One feature I really like is the Rule Tile to help create seemless tilemaps. However I was wondering how you can make these ruletiles interactive (e.g highlight individually/(be created/destroyed in game)/have different attriubutes etc.).
     
  2. guiguimanu

    guiguimanu

    Joined:
    Mar 6, 2017
    Posts:
    17
    I came across having to save some attributes in my rule tiles. Not sure if this is what you are looking for but the way I achieved this is by having RuleTile inherit a custom Tile class.

    eg.
    Code (CSharp):
    1. public class YourCustomTile : Tile {
    2.  
    3.     [SerializeField]
    4.     public float yourValue;
    5.  
    6. }
    and then have RuleTile.cs ineherit YourCustomTile
    Code (CSharp):
    1. public class RuleTile : YourCustomTile {
    2.     //rule tile code
    3. }
    Hope this helps!
     
    cwells1298 likes this.
  3. cwells1298

    cwells1298

    Joined:
    Jan 17, 2017
    Posts:
    5
    Havent done any Object Oriented Programming in Unity yet so never really thought of using the classes. Will try this out later, thanks.
     
    guiguimanu likes this.