Class GridInformation
A simple MonoBehaviour that stores and provides information based on Grid positions and keywords.
Implements
Inherited Members
Namespace: UnityEngine.Tilemaps
Assembly: Unity.2D.Tilemap.Extras.dll
Syntax
[Serializable]
[HelpURL("https://docs.unity3d.com/Packages/com.unity.2d.tilemap.extras@latest/index.html?subfolder=/manual/GridInformation.html")]
[AddComponentMenu("Tilemap/Grid Information")]
public class GridInformation : MonoBehaviour, ISerializationCallbackReceiver
Methods
ErasePositionProperty(Vector3Int, string)
Erases information stored at the given position with the given property name
Declaration
public bool ErasePositionProperty(Vector3Int position, string name)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3Int | position | Position to erase |
| string | name | Property name to erase |
Returns
| Type | Description |
|---|---|
| bool | Whether the information was erased |
GetAllPositions(string)
Gets all positions with information with the given property name
Declaration
public Vector3Int[] GetAllPositions(string propertyName)
Parameters
| Type | Name | Description |
|---|---|---|
| string | propertyName | Property name to search for |
Returns
| Type | Description |
|---|---|
| Vector3Int[] | An array of all positions with the property name |
GetPositionProperty(Vector3Int, string, double)
Retrieves double information stored at the given position with the given property name
Declaration
public double GetPositionProperty(Vector3Int position, string name, double defaultValue)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3Int | position | Position to retrieve information for |
| string | name | Property name to retrieve information for |
| double | defaultValue | Default double if property does not exist at the given position |
Returns
| Type | Description |
|---|---|
| double | The double stored at the position |
Exceptions
| Type | Condition |
|---|---|
| InvalidCastException | Thrown when information to be retrieved is not a double |
GetPositionProperty(Vector3Int, string, int)
Retrieves int information stored at the given position with the given property name
Declaration
public int GetPositionProperty(Vector3Int position, string name, int defaultValue)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3Int | position | Position to retrieve information for |
| string | name | Property name to retrieve information for |
| int | defaultValue | Default int if property does not exist at the given position |
Returns
| Type | Description |
|---|---|
| int | The int stored at the position |
Exceptions
| Type | Condition |
|---|---|
| InvalidCastException | Thrown when information to be retrieved is not a int |
GetPositionProperty(Vector3Int, string, float)
Retrieves float information stored at the given position with the given property name
Declaration
public float GetPositionProperty(Vector3Int position, string name, float defaultValue)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3Int | position | Position to retrieve information for |
| string | name | Property name to retrieve information for |
| float | defaultValue | Default float if property does not exist at the given position |
Returns
| Type | Description |
|---|---|
| float | The float stored at the position |
Exceptions
| Type | Condition |
|---|---|
| InvalidCastException | Thrown when information to be retrieved is not a float |
GetPositionProperty(Vector3Int, string, string)
Retrieves string information stored at the given position with the given property name
Declaration
public string GetPositionProperty(Vector3Int position, string name, string defaultValue)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3Int | position | Position to retrieve information for |
| string | name | Property name to retrieve information for |
| string | defaultValue | Default string if property does not exist at the given position |
Returns
| Type | Description |
|---|---|
| string | The string stored at the position |
Exceptions
| Type | Condition |
|---|---|
| InvalidCastException | Thrown when information to be retrieved is not a string |
GetPositionProperty(Vector3Int, string, Color)
Retrieves Color information stored at the given position with the given property name
Declaration
public Color GetPositionProperty(Vector3Int position, string name, Color defaultValue)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3Int | position | Position to retrieve information for |
| string | name | Property name to retrieve information for |
| Color | defaultValue | Default color if property does not exist at the given position |
Returns
| Type | Description |
|---|---|
| Color | The color stored at the position |
Exceptions
| Type | Condition |
|---|---|
| InvalidCastException | Thrown when information to be retrieved is not a Color |
GetPositionProperty<T>(Vector3Int, string, T)
Retrieves information stored at the given position with the given property name as the given Type
Declaration
public T GetPositionProperty<T>(Vector3Int position, string name, T defaultValue) where T : Object
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3Int | position | Position to retrieve information for |
| string | name | Property name to retrieve information for |
| T | defaultValue | Default value if property does not exist at the given position |
Returns
| Type | Description |
|---|---|
| T | The information stored at the position |
Type Parameters
| Name | Description |
|---|---|
| T | Type of the information to retrieve |
Exceptions
| Type | Condition |
|---|---|
| InvalidCastException | Thrown when information to be retrieved is not the given Type |
Reset()
Clears all information stored
Declaration
public virtual void Reset()
SetPositionProperty(Vector3Int, string, double)
Stores double information at the given position with the given property name
Declaration
public bool SetPositionProperty(Vector3Int position, string name, double positionProperty)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3Int | position | Position to store information for |
| string | name | Property name to store information for |
| double | positionProperty | The information to be stored at the position |
Returns
| Type | Description |
|---|---|
| bool | Whether the information was set |
SetPositionProperty(Vector3Int, string, int)
Stores int information at the given position with the given property name
Declaration
public bool SetPositionProperty(Vector3Int position, string name, int positionProperty)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3Int | position | Position to store information for |
| string | name | Property name to store information for |
| int | positionProperty | The information to be stored at the position |
Returns
| Type | Description |
|---|---|
| bool | Whether the information was set |
SetPositionProperty(Vector3Int, string, float)
Stores float information at the given position with the given property name
Declaration
public bool SetPositionProperty(Vector3Int position, string name, float positionProperty)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3Int | position | Position to store information for |
| string | name | Property name to store information for |
| float | positionProperty | The information to be stored at the position |
Returns
| Type | Description |
|---|---|
| bool | Whether the information was set |
SetPositionProperty(Vector3Int, string, string)
Stores string information at the given position with the given property name
Declaration
public bool SetPositionProperty(Vector3Int position, string name, string positionProperty)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3Int | position | Position to store information for |
| string | name | Property name to store information for |
| string | positionProperty | The information to be stored at the position |
Returns
| Type | Description |
|---|---|
| bool | Whether the information was set |
SetPositionProperty(Vector3Int, string, Color)
Stores color information at the given position with the given property name
Declaration
public bool SetPositionProperty(Vector3Int position, string name, Color positionProperty)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3Int | position | Position to store information for |
| string | name | Property name to store information for |
| Color | positionProperty | The information to be stored at the position |
Returns
| Type | Description |
|---|---|
| bool | Whether the information was set |
SetPositionProperty(Vector3Int, string, Object)
Stores UnityEngine.Object information at the given position with the given property name
Declaration
public bool SetPositionProperty(Vector3Int position, string name, Object positionProperty)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3Int | position | Position to store information for |
| string | name | Property name to store information for |
| Object | positionProperty | The information to be stored at the position |
Returns
| Type | Description |
|---|---|
| bool | Whether the information was set |
SetPositionProperty<T>(Vector3Int, string, T)
This is not supported.
Declaration
public bool SetPositionProperty<T>(Vector3Int position, string name, T positionProperty)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3Int | position | Position to store information for |
| string | name | Property name to store information for |
| T | positionProperty | The information to be stored at the position |
Returns
| Type | Description |
|---|---|
| bool | Whether the information was set |
Type Parameters
| Name | Description |
|---|---|
| T | Type of the information to set |
Exceptions
| Type | Condition |
|---|---|
| NotImplementedException | This is not implemented as only concrete Types are supported |