- Home /
Question by
KarasAya · Mar 09, 2011 at 01:40 PM ·
javascriptpragmastrictbce0022
Can't use for-in statement in strict javascript.
Hello, I'm writing a game using strict javascript in unity3d (#pragma strict), I wrote the code below in the Start function, but it reports error
#pragma strict
function Start () {
// Make all animations in this character play at half speed
for ( var state : AnimationState in animation ) {
state.speed = 0.5;
}
}
The compile error is:
BCE0022: Cannot convert 'Object' to 'UnityEngine.AnimationState'.
What should I do?
Comment
Answer by KarasAya · Mar 09, 2011 at 01:49 PM
Oh, Found the answer here: http://answers.unity3d.com/questions/26605/pragma-strict-and-for-var-childtransform-in-transform.
Solve it by add:
#pragma downcast