switched from Unity on PC to Mac and now Scripts don't work

I just bought a mac and the Unity iPhone license, and put my game I have been working on a PC for 5 months onto it. Many of the most important scripts in the game, that work great on the PC, are filling the console with errors on the Mac and the game won’t run.

Before getting into what all the errors are exactly (they mostly have to do with getComponent, I have been using that to access functions in other scripts), has anyone had this experience? If there is not a simple solution, I am looking at having to basically re-write the game…and I would really, really rather not do that.

Any input would be appreciated.

Thanks!

Matt

Are you using the Unity scripts that you wrote in Unity for Mac or are you using Unity iPhone for Mac? There is a big difference. Everything should work on PC or Mac just fine if you are talking about the normal Unity.

But Unity iPhone is different, and the difference has nothing to do with fact that it is on a Mac and everything to do with the fact that there are a lot of things you can do in Unity that you can not do on the iPhone. I’m sure if you look through the postings in the iPhone forum you will find lots of info about what needs to be done differently.

The most likely reason is that your scripts are written in Unity Script (aka Java Script), but without strict typing. Unity iPhone forces .JS files to use “#pragma strict” by default. This is to prevent your .JS files to become a bottleneck on a device that is much more limited in terms of processing power.

“#pragma strict” doesn’t mean you’ll have to rewrite your game, it means you will have to use strict typing. Explicitly setting the types of your variables and casting the results of functions like GetComponent using the ‘as’ keyword should solve most -if not all- of the errors.

Thanks for these responses!

It sounds like you are right, I will have to be more explicit with setting types of variables and so on.

I am new to programming, so to say that my code is written without “strict typing” would probably be an understatement.

I’ll try that tonight and see if I can clear those errors up that way.

yep…
you need to set variable types explicitly because default settings do not work well everywhere. I have also started programming recently and type casting troubles me most of the times…

Don’t put project to “fat32”. :wink: