I have a base abstract class Component
and a class GameObject
with a list of Components. I want to retrieve a component from that list but I can't figure out how.
public T GetComponent<T>() {
foreach (Component Component in Components) // Components is a list
if (Component is T)
return (T)(object)Component;
return (T)(object)null;
}