Hi,
I got a little Problem with my GetComponent in my delegate…
I got an Array full with GameObjects, every GameObject has a Script with the Name: GameObject.name + “Points”
Now i made a Method that Sorts my List by checking the value of AtkSpeed inside the Scripts:
public void SortTargetsByAtks(List<GameObject> unitList){
unitList.Sort(delegate(GameObject t1, GameObject t2){
return((t1.GetComponent(t1.name +"Points").stats.AtkSpeed.CompareTo(t2.GetComponent(t2.name + "Points").stats.AtkSpeed)));
});
}
This is the Error: error CS1061: Type UnityEngine.Component' does not contain a definition for
stats’ and no extension method stats' of type
UnityEngine.Component’ could be found (are you missing a using directive or an assembly reference?)
I know i can use GetComponent using
GetComponent<ScriptName>().stats.AtkSpeed
, but the Problem is i don’t know the ScriptName…
I hope someone can help me, but i Thank you already for just reading my Problem =D