Hi everyone,
I'm wondering if there is a way to access an enumeration value by it's index? I'm trying to iteratively populate a hashtable where the keys are enumeration values and the hashtable values are prefab objects. Something like this:
enum VehicleType {car, boat, airplane, motorcycle};
var vehiclePrefabs : Transform[];
private var vehicleModels : Hashtable;
function Start ()
{
vehicleModels = new Hashtable();
for (i = 0; i < vehiclePrefabs.length; i++)
{
vehicleModels.Add(VehicleType_, vehiclePrefabs*);*_
_*}*_
_*}*_
_*```*_
_*<p>This is so ultimately I can do this:</p>*_
_*```*_
_*function SpawnVehicle(vehicleType : VehicleType, spawnPoint : Vector3)*_
_*{*_
_*var spawnVehicle = Instantiate(vehicleModels[vehicleType], spawnPoint, Quaternion.identity);*_
_*}*_
_*```*_
<em>_<p>Now when I try to access the value by saying `VehicleType*` I get an error about "Type 'System.Type' does not support slicing."</p>*_</em>
<em>_*<p>I searched the forum a bit and found a post that mentions using `Enum.Getnames(VehicleType)`, but that seems to get all the names at once, and I want them one at a time. And I can't seem to find anywhere in the Scripting Reference that adequately describes what you can do with `Enum.`.</p>*_</em>
<em>_*<p>Any answers or clarification in what I'm doing wrong and what it's possible to do in terms of manipulating enumerations would be appreciated!</p>*_</em>
<em>_*<p>-Dylan</p>*_</em>