Reputation: 13
I have Tile
objects with an associated Tile.cs
file. These Tile
objects have a variable List<Transform> connections
that links them to other Tile objects.
I want to find the connections of connection (circled in green), here is a picture to be more clear:
link to picture : https://i.sstatic.net/Wwg1k.png
I can get the first connection (in red) with that code :
foreach(Transform t in connection)
{
t.GetComponent<Renderer>().material.color = Color.red;
}
and then I want the connection of each t
. I tryed to do t.gameObject.connection
, t.connection
, and other stuff that didn't work and I can't figure out how to do that...
Upvotes: 0
Views: 58
Reputation: 221
Get a tile component that is attached to t:
foreach(Transform t in connection)
{
t.GetComponent<Renderer>().material.color = Color.red;
var tConnections = t.GetComponent<Tile>().connection;
foreach(Transform tt in tConnections)
{
tt.GetComponent<Renderer>().material.color = Color.red;
}
}
Upvotes: 2