position | 瓦片在 Tilemap 上的位置。 |
tilemap | 瓦片所处的 Tilemap。 |
go | 为瓦片实例化的 GameObject。 |
bool 调用是否成功。
StartUp is called on the first frame of the running Scene.
Use this to set values for the instantiated GameObject or run any logic at the beginning of the Scene.
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; } }