#pragma strict and GetComponent

Hello,

I don’t get a problem with #pragma strict and the code below. I have an Array filled with all my "tradeNode"s; the components, not the GameObjects containing them. I’d like to call a function (Tick()) in every one of them. But if I do this:

var node : tradeNode;
  for (node in nodes) {
    node.Tick();	
}

However, this fails: “BCE0019: ‘Tick’ is not a member of ‘Object’.”

I fixed it like this:

var node : tradeNode;
  for (node in nodes) {
    var tmpNode : tradeNode = node as tradeNode;
    tmpNode.Tick();	
}

But that seems wrong somehow. As far as I see it, the “for (node in nodes)” doesn’t actually returns my component (“tradeNode”), but an “Object” - even though I’ve got the variable declared as the former. What am I missing here?

Don’t use Array, use a TradeNode[ ] array. Or List. if you need it to be dynamically sized. Everything in Array is Object, which is slow and not type safe.

–Eric

Ah, didn’t know that about Array(). Thanks!