- Home /
Implicit downcast and ArrayList
var animatedObjects : ArrayList = null;
// This gives: BCW0028: WARNING: Implicit downcast from 'Object' to 'AnimatedObject'.
for (var anim : AnimatedObject in animatedObjects)
{
}
Can somebody tell me how to fix this?
That error indicates a downcasting that's not implicity admitted - but your bit of code seems fine. Just a suggestion: try to add
#pragma implicit
#pragma downcast
At the beginning of your code. That would permit downcasting in an implicit way, I think. Let me now...
Answer by Fattie · Jan 17, 2012 at 01:38 PM
Here is a massive investigation of the issue !
http://answers.unity3d.com/questions/198318/javascript-array-use-with-a-struct-.html
In short (1) it can't be done and (2) one should use List anyway !!
For Javascript noobs: http://wiki.unity3d.com/index.php?title=Which_$$anonymous$$ind_Of_Array_Or_Collection_Should_I_Use%3F
The "List" you should be using ins$$anonymous$$d is "Generic List" aka List< T >
, which IS available in Unityscript if you add import System.Collections.Generic;
to the top of your script. See link.
Your answer
![](https://koobas.hobune.stream/wayback/20220613063107im_/https://answers.unity.com/themes/thub/images/avi.jpg)