Hi there Uniteers, I am in need of your help:
- I have a script called “QuestClass”.
- Several other scripts is derived from QuestClass, these are named Q01, Q02, Q03…
- Q01, Q02, Q03 is applied on a GameObject we call “QuestGiver”.
Okay, so in a secondary script, I want to reach these three Q-Scripts by using.
QuestClass[] tempArr = QuestGiver.GetComponents<QuestClass>();
foreach(QuestClass i in tempArr)
{
Debug.Log(i.GetType().toString();
}
What I get in return is:
Q1, Q1, Q1…
But what I expected was:
Q1, Q2, Q3…
The funny thing is, it recognizes at least how many scripts there is, so if there is five Q-scripts such as:
Q2, Q5, Q7, Q1, Q7…
It prints:
Q2, Q2, Q2, Q2, Q2
Is it just me who are missing something fundamentally about C# here or Unity? Perhaps I am doing it right, but the problem lies elsewhere? Feel free to ask questions, if I am not specific enough or haven’t made my self clear.