|
I've read through some forums, and I know the issue is related to Unity iPhone not supporting dynamic typing, but I still can't manage to get the syntax right on this one. Below is the syntax that works in standard Unity. -- here is a snip of code, where I'm trying to test if the int "idNumber" is the same as the int "idNumber" on the object a ray is hitting where "hit" is the Raycast and "touchingThreeScore" is the name of the script attached to (and that has the variable idNumber) and the transform that is held in thisTransform
(comments are locked)
|
Although probably you'd want to cache "thisTransform.GetComponent(touchingThreeScore)". This totally worked! Thank you! how would i go about caching the line you suggested? I guess my question really is, what type of item would it be? Component? or int? Thanks again!
Oct 31 '10 at 05:11 AM
Matt 15
(comments are locked)
|
|
Your code works fine in Unity 3. Ideally, you'd also GetComponent altogether, and use a generic list and the Find function, but UT hasn't supplied information about the appropriate syntax for lambdas in UnityScript, and I wouldn't bother with generic functions without them. This didn't help. His code actually doesn't work fine in Unity 3; anything with dynamic typing will fail when trying to make a build. GetComponent is slightly faster than using generics, so I wouldn't avoid it.
Oct 31 '10 at 04:29 AM
Eric5h5
I'll take your word on the dynamic typing thing, but that's terrible that there's no error generated prior to building. Interesting note on the GetComponent; do you have a link to results?
Oct 31 '10 at 01:59 PM
Jessy
When doing iOS scripts one should always put #pragma strict at the top, and that will solve the error generation problem. This used to be implicit in Unity iPhone when it was a separate app, but probably because of the cross-platform nature of Unity 3, that doesn't happen anymore. I don't have a link offhand, just some benchmarks I did.
Oct 31 '10 at 03:51 PM
Eric5h5
It's not like we still don't deal with iOS projects. It doesn't affect me much, because I don't use UnityScript, but I think it's pretty lame to have to throw that pragma in now.
Oct 31 '10 at 04:30 PM
Jessy
(comments are locked)
|
