Hey there, i want to know a solution for how i can stop writing the same lines of code again and again for other classes. I want to get rid of the if tree.
public void Test<T>() where T : class
{
if (typeof(T) == typeof(One))
{
One[] ones = FindObjectsOfType<One>();
foreach (One o in ones)
{
Something();
}
}
if (typeof(T) == typeof(Two))
{
Two[] twice = FindObjectsOfType<Two>();
foreach (Two t in twice)
{
Something();
}
}
// same code for other classes
}
Calling it with something like this:
...
Test<One>();
Some help would be great
Greets