Tuesday, March 27, 2012

Unity Quirks

Let the following Unity experiences be forever inscribed on the granite of the internet, available for Google searches by ambitious developers.

Developing for iOS

You can't develop for iOS on a Windows machine. You can see the option for building on this platform by clicking File -> Build Settings, and then selecting iOS. I did not try using any hack to emulate a mac on my Windows machine, so feel free to comment with instructions if you've tried that and succeeded.

Developing for Android

Problem: Images show up black when run on actual Android device.
Solution: Reduce the resolution of your image. You can do this by selecting the image from your Project listing, then by changing the Max Size property to something lower. Note that this will reduce the resolution of your picture. Further instances of this problem were resolved by changing the shader to "Mobile -> Unlit", which you can access by selecting your shader and manipulating its Shader drop-down property.
Tried with no success:
  • Changing JPG to PNG
  • Changing material to Mobile/Diffuse (no impact on size of apk, by the way...)
  • Setting image Max Size property from 4096 to 1024 (loss of resolution). This fixed it and reduces the size of the apk!
Problem: Google Wallet requires manifest file details in order to function.
Solution: Unknown.
Tried with no success: Researching.

Problem: A plane, or other GameObject model, does not update its position when run on my Android device. Also known as: the Unity editor does not reflect the actual values being changed in the script (javascript, C#) files.
Solution: Firstly, use the editor to set the public variables in your scripts. If you're like me and prefer code, you can provoke Unity to refresh these values by doing the following.
  1. Make your variables in question private.
  2. Save that file.
  3. Check your editor; it will refresh and not show your variables. Run the game for good measure.
  4. Make those variables public again -- for good measure, do that after you've manually synchronized the values to what the editor shows.

At that point, your values should act as expected. I tend to also restart Unity because I'm paranoid.

Parks originally gave me this "hack" for a different problem, but it's been useful for general desynchs between the editor and script files.

2 comments:

Anonymous said...

Found this blog post a bit late. Ended up already solving my problem, but I figured I'd clarify it in case someone else runs into it.

The issue with black textures is a maximum texture size supported by the device. If the texture is over that size, it appears as just black. Hence, lowering max texture size fixes the problem.

You can look at max texture size per-device here:
http://gfxbench.com/device.jsp?D=Motorola+Droid+%28Milestone+Sholes%29&testgroup=gl&benchmark=glpro20

For apple devices the list can be found here:
http://i.stack.imgur.com/kZWdQ.png

Danny Favela said...

Glad the blog belatedly helped!