Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Andrew 5 · Jul 28, 2010 at 04:58 AM · javascriptiphone

Unity iPhone and Unity Desktop Scripting Differences

I was developing a game in Unity Basic but recently purchased Unity iPhone Basic to release the game on the iPad. Everything seems to look ok, except I am having a few weird script errors.

One: Operator '-' cannot be used with a left hand side of type 'Object' and a right hand side of type 'Object'.

var balls = GameObject.FindGameObjectsWithTag("Ball");

 var zs = new Array();
 var ys = new Array();


 for(var i = 0; i < balls.length; i++){
     zs[i] = balls[i].transform.position.z;
     ys[i] = balls[i].transform.position.y;
 }


 ys.Sort();
 zs.Sort();


 var zdiff = zs[zs.length-1] - zs[0]; // ERRORS HAPPEN HERE
 var ydiff = ys[ys.length-1] - ys[0]; // ERRORS HAPPEN HERE

What is wrong with the code? It works perfectly in both Windows and Mac Unity Basic... Are there any huge differences that I should know of between Unity iPhone and Desktop when scripting?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
3
Best Answer

Answer by Eric5h5 · Jul 28, 2010 at 05:13 AM

The main difference is that you can't use dynamic typing on Unity iPhone. (Basically all Javascript has an invisible "#pragma strict" applied to it.) In this particular case you have to cast the array as the appropriate type.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Andrew 5 · Jul 28, 2010 at 05:16 AM 0
Share

Thank you for your help!

avatar image
1

Answer by Ashkan_gc · Jul 28, 2010 at 05:14 AM

there is not much difference, specially if you enable .net 2.0 features then most things will be the same but you should write a really fast code to be able to run it on an iphone. however ipad is much faster. take a look at this

the only feature that is not supported is dynamic typing so your array should be casted to the original type and then anything will be correct and you are good to go.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

Flipping textures 0 Answers

Can someone help me fix my Javascript for Flickering Light? 6 Answers

Setting Scroll View Width GUILayout 1 Answer

How do I invert the Y axis in Penelope tutorial? 3 Answers

Reading line-wise? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges