I’ve got this function working as an Instantiate, meaning that it needs a string, a position and a rotation.
Using a system I made, I can implement the position and the rotation, but I’ve got troubles with the string.
I need to call on something using the result of an enum.
So I’ve got this enum:
public enum enumType {ONE, TWO, THREE, FOUR};
public enumType type;
But since it’s giving me an int, I cannot convert this to a string. The enum is important because it allows me to set things appropriately.
Is there any way that I could “interpret” the result of the enum so that I could send a correct string to my function?
In my case, if I ain’t wrong, the result is always passed like some sort of string. It only works as an int if a do an explicit conversion, like the one I show before.
Well, interestingly in your enum ONE is actually zero, TWO is one, and so on. So even if you just used .ToString() on the int representation of the enumeration value, you will not technically get the correct results. To change this, make your enum like this:
public enum enumType
{
ONE = 1,
TWO,
THREE,
FOUR
}
int values should have a ToString() function available in C# that gives you the string representation of the number.
string enemy = Enum.GetName(typeof(Wave.enemyType), waves[currentWave].type);
where Wave.enemyType is my enum, and waves.type is the variable of my enum.