position | 瓷砖在Tilemap上的位置。 |
tilemap | 瓷砖所在的Tilemap。 |
go | 为瓷砖实例化的GameObject。 |
bool 调用是否成功。
StartUp 在运行场景的第一帧被调用。
使用它为实例化的GameObject设置值或在场景开始时运行任何逻辑。
using UnityEngine; using UnityEngine.Tilemaps;
// Tile that instantiates a GameObject on Start and assigns a random rotation to the instanced GameObject [CreateAssetMenu] public class RandomRotationStartupTile : TileBase { public Sprite m_Sprite; public GameObject m_Prefab;
public override void GetTileData(Vector3Int location, ITilemap tilemap, ref TileData tileData) { tileData.sprite = m_Sprite; tileData.gameObject = m_Prefab; }
public override bool StartUp(Vector3Int location, ITilemap tilemap, GameObject go) { if (go != null) { go.transform.rotation = Random.rotation; } return true; } }