タイルマップに追加するタイルは全て TileBase
から継承されている必要があります。 TileBase
は、特定の API 一式をタイルマップに提供して、レンダリングのプロパティを伝えます。ほとんどの API では、タイルの場所およびそのタイルが置かれているタイルマップのインスタンスが API の引数として渡されます。これを利用してタイル情報の設定時に必要な属性を特定することも可能です。
public void RefreshTile(Vector3Int location, ITilemap tilemap)
RefreshTile
― そのタイルがタイルマップに追加された時に更新される近接タイルを決定します。デフォルトでは TileBase
は tilemap.RefreshTile(location)
を呼び出してタイルを現在の場所でリフレッシュします。これをオーバーライドすると、新しいタイルの配置によってリフレッシュが必要になったタイルを特定できます。
(例) 直線道路が 1 本あり、その隣に RoadTile
を配置するとします。直線道路が無効になり、代わりに T 字路が必要になります。 Unity は、何のリフレッシュが必要かを自動的には判定しないため、 RoadTile
はそれ自体のみならず隣接した道路のリフレッシュをトリガーする必要があります。
public bool GetTileData(Vector3Int location, ITilemap tilemap, ref TileData tileData)
GetTileData
― タイルマップ上でタイルがどのように表示されるかを特定します。詳細は下記の TileData
の項をご覧ください。
public bool GetTileAnimationData(Vector3Int location, ITilemap tilemap, ref TileAnimationData tileAnimationData)
GetTileAnimationData
― アニメーション化されるタイルかどうかを特定します。タイルにアニメーションがある場合は true を、ない場合は false を戻します。
public bool StartUp(Vector3Int location, ITilemap tilemap, GameObject go)
StartUp
は、タイルマップの初回更新時に各タイルに呼び出されます。必要に応じて、タイルマップ上のタイル用に任意のスタートアップ ロジックを実行することも可能です。引数 go はインスタンス化されたオブジェクトで、 GetTileData
が呼び出された際にゲームオブジェクトとして渡されたものです。 go も必要に応じて更新することができます。
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.