Send any class into a void?

Hey guys, i’m trying to figure out if it is possible to send any class into a void?

private void Test(Behaviour anyClass)
{
    anyClass[] any= FindObjectsOfType<anyClass>();
    foreach (anyClass a in any)
    {
      Debug.Log("Found!");
    }
}

So i want to create an array of the class wich i send in.

Would be great to find a solution :slight_smile:

Ty

If i understod right what you looking for is generic type, the basic code is:

public void Test<T>(T p_class)
    {

    }

for more details on generic see this tutorial:

In your case, this is the only solution i can think of (If you don’t have too many classes) :

    public void AcceptAnyClass(object anyClass)
    {

        if(anyClass is ClassA)
        {
            ClassA[] any = FindObjectsOfType<ClassA>();
            foreach (ClassA a in any)
            {
                Debug.Log("Found!");
            }
        }
        else if (anyClass is ClassB)
        {
            ClassB[] any = FindObjectsOfType<ClassB>();
            foreach (ClassB a in any)
            {
                Debug.Log("Found!");
            }
        }
        else if (anyClass is ClassC)
        {
            ClassC[] any = FindObjectsOfType<ClassC>();
            foreach (ClassC a in any)
            {
                Debug.Log("Found!");
            }
        }
    }