Search Unity

Adding scripts to Tiles

Discussion in '2D' started by ElnuDev, Jul 17, 2018.

  1. ElnuDev

    ElnuDev

    Joined:
    Sep 24, 2017
    Posts:
    298
    How do you add scripts to tiles in a tilemap? I tried making this script:

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.Tilemaps;
    5. using UnityEditor;
    6.  
    7. public class RepairKitTile : Tile {
    8.  
    9.     // Use this for initialization
    10.     void Start () {
    11.        
    12.     }
    13.    
    14.     // Update is called once per frame
    15.     void Update () {
    16.        
    17.     }
    18. }
    It appeared like this in the Editor:

    upload_2018-7-17_13-4-36.png

    However, I cannot drag it into the Tile Palette. Any ideas?
     
  2. barskey

    barskey

    Joined:
    Nov 19, 2017
    Posts:
    207
    Tiles are intermediary assets. To add components, like scripts, you will need to create your own class based on the TileBase class with your custom code.

    See this thread for similar question.