Question by
Tigermisu · Feb 23, 2016 at 02:32 PM ·
c#inheritance
Super quick question about inheritance and GetComponent()
Suppose I have class Enemy, and I create a child class called Wizard.
Gameobject John has Wizard component in him. If via my script I call John.GetComponent<Enemy>();
will I get the Wizard component?
In other works, does calling GetComponent on the parent class return any child class of it?
Comment
Answer by NoseKills · Feb 23, 2016 at 05:16 PM
Yes it works like that. 2 hours... would've been faster to just try i guess :)
Your answer
Follow this Question
Related Questions
How would I get around multiple inheritance for this instance? 1 Answer
Protected variable is assigned in parent but null in child 1 Answer
Custom class, Null Reference Exception 4 Answers
C# syntax question Generic and overriding 0 Answers
Grab an inherited subclass script from a GameObject in C# 0 Answers