Thursday, May 10, 2012

Android, Shaders and Unity

Here the short lessons I learned this week that you may be able to benefit from.

Porting Unity Code from PC to Android?
  • Schedule at least 1-2 weeks to ensure code runs the same.
  • Android Virtual machine is slow.  Iteration takes 3-15 mins or more.
  • Unity Shaders will drive you crazy
  • Some code libraries don't work. (like Lists on iPhone) - edit: In latest revisions these work now

Here's the story behind it.

As much as those reading may be frustrated with delays, I assure you, I am even more so.  I've been constantly changing things up to ensure better results.

Last week I pushed up android testing.  I was going to do it after the web version of Dots looked decent.  Instead it's happening right now.  Unity touts being pretty much click and export.  No porting involved.   While much better than say a flash port, it's still far from true.

After porting the game over all I got was a pink screen.  At first I was worried may have bricked my new android.  But turns out it was just the shaders in unity weren't displaying properly.

I've thus spent the WEEK trying to get things working.   The biggest problem is you can't easily test changes.  You compile code, you upload it onto the virtual android machine and see if it worked.  One line of code takes about 10-15 mins to see the results.

The first thing I tried was the mobile shaders provided in Unity.  But at best they were very dark.  I needed unlit shaders with transparency.   I've been searching IRC, forums etc. while compiling different tweaks.  It's better but still not there yet.

Once that is done I still have to make sure all gameplay is working with touch controls.

One more thing, I read certain code will not work.  I program in C# and use Lists instead of arrays.  Lists work fine on the PC and Android, but don't work on the iPhone as that library isn't included.   I wish there was a list of what exactly did work and what didn't, but it seems most of it is trial and error.

Remember the dangers of working with new systems?  Well this is what I have to fight every week. It gets better, but sometimes it seems like a complete relapse.  But ah, thats the way things go.

1 comment:

  1. If things get messy with UNITY try I didn't work with it yet, but support all mayors platforms.


Please no spam, and no links unless they directly relate to the content of the page.