How do i make a function/method that receives a generic enum ?

Something like :

using System;

void method(Enum enum_)
{
    for(int i=0;i<Enum.GetNames(enum_).Length-1;i++)
    {
        print(i);
    }
}

I’v tried to use some example i’v found in google, but they won’t work in unity, any idea how to make it work ?

“Enum” is a special type, like the type of a type- a “keyword” and not something you can use for anything other than creating an enum type of your own. If you found it while googling, they were probably using it as a representation of an enum type rather than a literal script that could be plugged in and run as-is. Usually you’ll see MyEnum or TestEnum instead, but occasionally just plain “enum” is all they give. Define your own enum type (there is no Generic or Default version) and you’ll be able to use it as a parameter this way.

In a somewhat related note, it’s important to consider that enums play a slightly different role in Unity than they do in the .NET structure, because in .NET it’s very possible (even highly suggested) that enums are given a global scope, in which case needing to pass them into functions this way would be meaningless. In Unity, because “globals” don’t really exist in the same way, you should just give them a static position for a public class and achieve a similar result.

Thanks for the detailed answer Lysander! Much appreciated.