Reputation: 71
I've wanted to create a function with an enum at the parameters so I just can go in unity and change the value easily, but it gives me an error and I don't know why. I'm really new in programming so pls dont judge me to hard :D
void TestFunction(enum TestEnum { name1, name2, name3})
{
}
Upvotes: 0
Views: 421
Reputation: 96
You can't declare an enum inside a function you have to first declare the enum like this
enum TestEnum {
name1,
name2,
name3
}
And then you can use it as a parameter
void TestFunction(TestEnum testEnum) {
// Do Something
}
Upvotes: 1