Class RuleTile
Generic visual tile for creating different tilesets like terrain, pipeline, random or animated tiles.
Inherited Members
Namespace: UnityEngine
Syntax
[Serializable]
[HelpURL("https://docs.unity3d.com/Packages/com.unity.2d.tilemap.extras@latest/index.html?subfolder=/manual/RuleTile.html")]
public class RuleTile : TileBase
Fields
m_DefaultColliderType
The Default Collider Type set when creating a new Rule.
Declaration
public Tile.ColliderType m_DefaultColliderType
Field Value
Type | Description |
---|---|
Tile.ColliderType |
m_DefaultGameObject
The Default GameObject set when creating a new Rule.
Declaration
public GameObject m_DefaultGameObject
Field Value
Type | Description |
---|---|
GameObject |
m_DefaultSprite
The Default Sprite set when creating a new Rule.
Declaration
public Sprite m_DefaultSprite
Field Value
Type | Description |
---|---|
Sprite |
m_TilingRules
A list of Tiling Rules for the Rule Tile.
Declaration
[HideInInspector]
public List<RuleTile.TilingRule> m_TilingRules
Field Value
Type | Description |
---|---|
List<RuleTile.TilingRule> |
Properties
m_NeighborType
Returns the default Neighbor Rule Class type.
Declaration
public virtual Type m_NeighborType { get; }
Property Value
Type | Description |
---|---|
Type |
m_RotationAngle
Angle in which the RuleTile is rotated by for matching in Degrees.
Declaration
public virtual int m_RotationAngle { get; }
Property Value
Type | Description |
---|---|
Int32 |
m_RotationCount
Number of rotations the RuleTile can be rotated by for matching.
Declaration
public int m_RotationCount { get; }
Property Value
Type | Description |
---|---|
Int32 |
neighborPositions
Returns a set of neighboring positions for this RuleTile
Declaration
public HashSet<Vector3Int> neighborPositions { get; }
Property Value
Type | Description |
---|---|
HashSet<Vector3Int> |
Methods
ApplyRandomTransform(RuleTile.TilingRuleOutput.Transform, Matrix4x4, Single, Vector3Int)
Returns a random transform matrix given the random transform rule.
Declaration
public virtual Matrix4x4 ApplyRandomTransform(RuleTile.TilingRuleOutput.Transform type, Matrix4x4 original, float perlinScale, Vector3Int position)
Parameters
Type | Name | Description |
---|---|---|
RuleTile.TilingRuleOutput.Transform | type | Random transform rule. |
Matrix4x4 | original | The original transform matrix. |
Single | perlinScale | The Perlin Scale factor of the Tile. |
Vector3Int | position | Position of the Tile on the Tilemap. |
Returns
Type | Description |
---|---|
Matrix4x4 | A random transform matrix. |
GetCustomFields(Boolean)
Returns custom fields for this RuleTile
Declaration
public FieldInfo[] GetCustomFields(bool isOverrideInstance)
Parameters
Type | Name | Description |
---|---|---|
Boolean | isOverrideInstance | Whether override fields are returned |
Returns
Type | Description |
---|---|
FieldInfo[] | Custom fields for this RuleTile |
GetMirroredPosition(Vector3Int, Boolean, Boolean)
Gets a mirrored position given its original position and the mirroring axii.
Declaration
public virtual Vector3Int GetMirroredPosition(Vector3Int position, bool mirrorX, bool mirrorY)
Parameters
Type | Name | Description |
---|---|---|
Vector3Int | position | Original position of Tile. |
Boolean | mirrorX | Mirror in the X Axis. |
Boolean | mirrorY | Mirror in the Y Axis. |
Returns
Type | Description |
---|---|
Vector3Int | Mirrored position of Tile. |
GetOffsetPosition(Vector3Int, Vector3Int)
Get the offset for the given position with the given offset.
Declaration
public virtual Vector3Int GetOffsetPosition(Vector3Int position, Vector3Int offset)
Parameters
Type | Name | Description |
---|---|---|
Vector3Int | position | Position to offset. |
Vector3Int | offset | Offset for the position. |
Returns
Type | Description |
---|---|
Vector3Int | The offset position. |
GetOffsetPositionReverse(Vector3Int, Vector3Int)
Get the reversed offset for the given position with the given offset.
Declaration
public virtual Vector3Int GetOffsetPositionReverse(Vector3Int position, Vector3Int offset)
Parameters
Type | Name | Description |
---|---|---|
Vector3Int | position | Position to offset. |
Vector3Int | offset | Offset for the position. |
Returns
Type | Description |
---|---|
Vector3Int | The reversed offset position. |
GetPerlinValue(Vector3Int, Single, Single)
Returns a Perlin Noise value based on the given inputs.
Declaration
public static float GetPerlinValue(Vector3Int position, float scale, float offset)
Parameters
Type | Name | Description |
---|---|---|
Vector3Int | position | Position of the Tile on the Tilemap. |
Single | scale | The Perlin Scale factor of the Tile. |
Single | offset | Offset of the Tile on the Tilemap. |
Returns
Type | Description |
---|---|
Single | A Perlin Noise value based on the given inputs. |
GetRotatedPosition(Vector3Int, Int32)
Gets a rotated position given its original position and the rotation in degrees.
Declaration
public virtual Vector3Int GetRotatedPosition(Vector3Int position, int rotation)
Parameters
Type | Name | Description |
---|---|---|
Vector3Int | position | Original position of Tile. |
Int32 | rotation | Rotation in degrees. |
Returns
Type | Description |
---|---|
Vector3Int | Rotated position of Tile. |
GetTileAnimationData(Vector3Int, ITilemap, ref TileAnimationData)
Retrieves any tile animation data from the scripted tile.
Declaration
public override bool GetTileAnimationData(Vector3Int position, ITilemap tilemap, ref TileAnimationData tileAnimationData)
Parameters
Type | Name | Description |
---|---|---|
Vector3Int | position | Position of the Tile on the Tilemap. |
ITilemap | tilemap | The Tilemap the tile is present on. |
TileAnimationData | tileAnimationData | Data to run an animation on the tile. |
Returns
Type | Description |
---|---|
Boolean | Whether the call was successful. |
Overrides
GetTileData(Vector3Int, ITilemap, ref TileData)
Retrieves any tile rendering data from the scripted tile.
Declaration
public override void GetTileData(Vector3Int position, ITilemap tilemap, ref TileData tileData)
Parameters
Type | Name | Description |
---|---|---|
Vector3Int | position | Position of the Tile on the Tilemap. |
ITilemap | tilemap | The Tilemap the tile is present on. |
TileData | tileData | Data to render the tile. |
Overrides
RefreshTile(Vector3Int, ITilemap)
This method is called when the tile is refreshed.
Declaration
public override void RefreshTile(Vector3Int position, ITilemap tilemap)
Parameters
Type | Name | Description |
---|---|---|
Vector3Int | position | Position of the Tile on the Tilemap. |
ITilemap | tilemap | The Tilemap the tile is present on. |
Overrides
RuleMatch(Int32, TileBase)
Checks if there is a match given the neighbor matching rule and a Tile.
Declaration
public virtual bool RuleMatch(int neighbor, TileBase other)
Parameters
Type | Name | Description |
---|---|---|
Int32 | neighbor | Neighbor matching rule. |
TileBase | other | Tile to match. |
Returns
Type | Description |
---|---|
Boolean | True if there is a match, False if not. |
RuleMatches(RuleTile.TilingRule, Vector3Int, ITilemap, Boolean, Boolean)
Checks if there is a match given the neighbor matching rule and a Tile with mirrored axii.
Declaration
public bool RuleMatches(RuleTile.TilingRule rule, Vector3Int position, ITilemap tilemap, bool mirrorX, bool mirrorY)
Parameters
Type | Name | Description |
---|---|---|
RuleTile.TilingRule | rule | Neighbor matching rule. |
Vector3Int | position | Position of the Tile on the Tilemap. |
ITilemap | tilemap | Tilemap to match. |
Boolean | mirrorX | Mirror X Axis for matching. |
Boolean | mirrorY | Mirror Y Axis for matching. |
Returns
Type | Description |
---|---|
Boolean | True if there is a match, False if not. |
RuleMatches(RuleTile.TilingRule, Vector3Int, ITilemap, Int32)
Checks if there is a match given the neighbor matching rule and a Tile with a rotation angle.
Declaration
public bool RuleMatches(RuleTile.TilingRule rule, Vector3Int position, ITilemap tilemap, int angle)
Parameters
Type | Name | Description |
---|---|---|
RuleTile.TilingRule | rule | Neighbor matching rule. |
Vector3Int | position | Position of the Tile on the Tilemap. |
ITilemap | tilemap | Tilemap to match. |
Int32 | angle | Rotation angle for matching. |
Returns
Type | Description |
---|---|
Boolean | True if there is a match, False if not. |
RuleMatches(RuleTile.TilingRule, Vector3Int, ITilemap, ref Matrix4x4)
Does a Rule Match given a Tiling Rule and neighboring Tiles.
Declaration
public virtual bool RuleMatches(RuleTile.TilingRule rule, Vector3Int position, ITilemap tilemap, ref Matrix4x4 transform)
Parameters
Type | Name | Description |
---|---|---|
RuleTile.TilingRule | rule | The Tiling Rule to match with. |
Vector3Int | position | Position of the Tile on the Tilemap. |
ITilemap | tilemap | The tilemap to match with. |
Matrix4x4 | transform | A transform matrix which will match the Rule. |
Returns
Type | Description |
---|---|
Boolean | True if there is a match, False if not. |
StartUp(Vector3Int, ITilemap, GameObject)
StartUp is called on the first frame of the running Scene.
Declaration
public override bool StartUp(Vector3Int position, ITilemap tilemap, GameObject instantiatedGameObject)
Parameters
Type | Name | Description |
---|---|---|
Vector3Int | position | Position of the Tile on the Tilemap. |
ITilemap | tilemap | The Tilemap the tile is present on. |
GameObject | instantiatedGameObject | The GameObject instantiated for the Tile. |
Returns
Type | Description |
---|---|
Boolean | Whether StartUp was successful |
Overrides
UpdateNeighborPositions()
Updates the neighboring positions of this RuleTile
Declaration
public void UpdateNeighborPositions()