- Home /
What is the syntax for adding some generic type of component without an object reference?
I want something like this,
void M <T> (T t) {go.AddComponent<T>()};
but with the ability to just do something like
M(BoxCollider);
How?
Comment
Best Answer
Answer by Mike 3 · Oct 05, 2010 at 04:10 PM
Something like this:
void M <T>() { go.AddComponent(typeof(T)); }
then you'd just use
M<BoxCollider>();