Reference creator of gameObject

Hi,

This is more of a general theory question. I have a 2D grid of tile objects, which each have a gameObject which gives the object it’s presence in the game world.
The tile object also holds an (x,y) coordinate pair, which is not equivalent to its real world position.

Is there any easy way of getting access to the tile objects variables through an event where the gameObject is clicked? At present, I can find no way of accessing the tileObject, as it references the gameObject, but the reverse is not true.

Thanks

If you have a reference to the game object, you can use GetComponent() to get access to the Tile component:

http://docs.unity3d.com/412/Documentation/ScriptReference/index.Accessing_Other_Components.html

http://docs.unity3d.com/412/Documentation/ScriptReference/index.Accessing_Other_Game_Objects.html

There are multiple ways of using GetComponent(). I suggest the generic version:

Tile tile = gameObject.GetComponent<Tile>();