Getting typename from collection.
I'm curious how exactly Unity has implemented the GetComponent function.
Assuming some sort of collection is storing the components -
public T GetComponent<T>() where T : Component
{
????
}
How do we find a component of type T inside of the collection? Another question is how would you enforce unique components based on Type? For example the component collection couldn't store two FooComponent : Component types.
I'm aware that we can get typeof(T) and compare that type to each in the collection to find a match but I'm curious if there's a better way to do so.
Your answer
Follow this Question
Related Questions
How do I shorten a gameObject.GetComponent 1 Answer
Remove connection between lists or arrays 3 Answers
How to make a surface glow when its hit by a laser. 0 Answers
Hiding part of mesh 0 Answers
C# for applications vs C# for Unity help 3 Answers