Question by
UnityError · Oct 27, 2020 at 01:02 AM ·
c#components
GetComponent of a class of generic type
Let say i have a monobehavior class UpgradableBuilding T where T : BuildingUpgrade. How can i get the component UpgradableBuilding of whatever superclass T of BuildingUpgrade? I mean if the UpgradableBuilding script is attached to a gameObject, when i use the GetComponent method i have to specify the generic class T, but how can i retrieve this component indipendently of the class T, or better for whatever class that is T?
Comment
Your answer
Follow this Question
Related Questions
How would I figure out what type a component is,Getting the type of a component 1 Answer
How to get parent with component on collision? 0 Answers
Edit variable of component by type 0 Answers
Freezing an object and keeping it's velocity 1 Answer
Is there a way for children to know if a parent is deactivated? 2 Answers