using System; using System.Collections.Generic; using System.Reflection; using UnityEngine; using UnityEngine.Tilemaps; namespace UnityEditor.Tilemaps { /// /// Use this attribute to add an option to customize how Tiles are created when dragging and dropping assets to the Tile Palette. /// /// /// Append this attribute to a method that has a signature of "static TileBase CreateTile(Sprite sprite)". /// /// /// (); /// blueTile.sprite = sprite; /// blueTile.name = sprite.name; /// blueTile.color = Color.blue; /// return blueTile; /// } /// } /// ]]> /// [AttributeUsage(AttributeTargets.Method)] public class CreateTileFromPaletteAttribute : Attribute { private static List m_CreateTileFromPaletteMethods; internal static List createTileFromPaletteMethods { get { if (m_CreateTileFromPaletteMethods == null) GetCreateTileFromPaletteAttributeMethods(); return m_CreateTileFromPaletteMethods; } } [RequiredSignature] private static TileBase CreateTile(Sprite sprite) { return null; } private static void GetCreateTileFromPaletteAttributeMethods() { m_CreateTileFromPaletteMethods = new List(); foreach (var sortingMethod in TypeCache.GetMethodsWithAttribute()) { m_CreateTileFromPaletteMethods.Add(sortingMethod); } } } }