- Home /
Array of transforms with "labels"
What I'm trying to accomplish for my game is an array that will store transforms. So, of course I'm using "Transform[]" to achieve this. However, what I want to be able to do in the inspector is label the transform. For example:
I create an array called spawnPoints. Within this array, three different transforms are stored. However, I want to label these transforms like:
"Front", transform1
"Back", transform2
"Roof", transform3
And so I would be able to access these transforms again later by referring to the string value.
How would I go about in doing so?
Answer by Eric5h5 · Jun 06, 2013 at 08:15 PM
You would normally use a Dictionary for something like that, specifically Dictionary.< String, Transform >
. However Dictionaries don't show up in the inspector, unless you write a custom inspector for it. Or you could make a class that contains a String and a Transform, and have an array of that class (which will show in the inspector without having to do anything special), then convert that array to a Dictionary in Awake.
Thank you! I had forgotten about dictionaries. Thank you!