Archive for the 'Unity Android' Category

Upgrading Unity Android, or How I learned to embrace masochism…

I’ve been working on a game for about a year called The Secret Castle. It’s coming along great and we’re getting really close to release. We’re launching for both Android and iOS, and I’ve been doing the bulk of the work on my PC (I can’t seem to live without multiple monitors).

I ran got burned during the great upgrade of 3.3 and swore that I wouldn’t ever upgrade my main development box again without testing it out in a VM or something first. I’ve been working on 3.4.2 for a while with no problems, and I had been ignoring the upgrade nags about 3.5.2 until I finally had some time to test the upgrade in a VM.

So, I fire up Virtual Box, upgrade my project – everything works fine. Test successfully complete. OK – on to the real thing!

I upgrade my development machine, everything also works fine. No errors, no warnings, it’s all looking good. I then connect up my tablet and try to build to it:


 Failed to re-package resources with the following parameters:
 package -v -f -m -J gen -M AndroidManifest.xml -S "res" -I "C:/Program Files (x86)/Android/android-sdk-windows/platforms/android-Honeycomb\android.jar" -F bin/resources.ap_
 Configurations:
 (default)
 hdpi Continue reading 'Upgrading Unity Android, or How I learned to embrace masochism…'
Advertisements

Writing Unity Custom Editors in C#

As your games become more complex you’re probably going to start to get frustrated with how complex the Unity Inspector can be. Editing 4 different arrays all containing linked information about an object and keeping it all in sync can start to add up, especially if you’re building these tools for game designers to come behind you and use or tweak. Writing custom editors for the inspector is an incredibly useful tool for keeping it clean and manageable on the surface while being complex under the covers.

Ok, enough trying to sell you on using customer editors. I recently decided to write a custom editor in c# and found that the documentation only gives you code for JavaScript. After grinding it out for a bit I finally figured out how to do it in C#: Continue reading ‘Writing Unity Custom Editors in C#’

Unity Android and OpenGL ES 2.0 – another cautionary tale…

In my previous post I mentioned how excited I was to finally get over a huge crashing issue I had with Zombie Room AR. While that post is still completely accurate, my total celebration was a little premature. A couple of days after pushing out the latest fixes I got another email from a user experiencing a crash… Seriously!? I just.. but I… come on…

So here I sat with ANOTHER crash happening – this one was crashing in the exact same way, and once again it wasn’t putting together a report of a stack trace for me to find the underlying problem. Whiskey sure is tasty! Continue reading ‘Unity Android and OpenGL ES 2.0 – another cautionary tale…’

Unity Android and the Android Market Licensing (LVL) – a cautionary tale…

If you’ve been following this blog then you no doubt know all about my augmented reality game Zombie Room AR. What you may not know is how much of a struggle I’ve had trying to support it. If you look at the demo version in the android market you’ll see a crap  load of 1 star reviews saying the game crashes and that I suck and other idiotic comments. Over the past year I’ve been an Android developer and I know that the Star ratings and comments are on par with youtube comments, so I’ve brushed most of these off…

Unfortunately, the one thing these comments have in common is that they’re right… the game just crashes on a lot of devices… mysterious crashes that leave me scratching my head in wonder. The strangest thing is that when the game crashes, it just sort of exits. Typically when a program crashes on Android you get a box pop up with a “Force Close” or “Report” option. If you click “Report” it sends a stack trace to the developer, which will give him a clue about what the problem is. I never got one stack trace, so I had absolutely nothing to go off of. I have 4 different Android devices I test against I have not ever been able to reproduce this issue. In some cases I’ve had customers reach out to me by email asking what the deal is… and I’ve never had a good answer for it… Until today. Continue reading ‘Unity Android and the Android Market Licensing (LVL) – a cautionary tale…’

Accessing the Android Compass through Unity 3D.

OK, let’s go ahead and get this out of the way. This post is not for beginners or the faint of heart. There is no way to access Android’s Magnetic Field Sensor (aka the compass) directly from Unity, so in order to do that we’re going to have to write a custom plugin. This is not an easy task, and I honestly don’t know how well I can explain it – so… stick with me and hopefully we’ll get through this together. (Note: At the time of this writing I’m using Unity 3.4 so if you’re a traveler from the distant future, I don’t know how much of this will still be valid)

Quick Overview of custom plug-ins:

Writing a custom plugin is very poorly documented, and anyone who does it pretty much has to figure it all out by themselves. For Android, here’s the process:

1. Write a custom Java jar file.
2. Write a C(++) library using JNI to access the jar file and compile it into a .so file using Android NDK
3. Import the DLL (.so file) into C# script inside unity and access all the magic.

Now, I’m not that great of a C developer, so I opted to do the following instead:

1. Write a custom Java jar file.
2. Use the AndroidJNI helper function embedded in Unity to access the jar file.

The latter method is the one we’re going to use today. Continue reading ‘Accessing the Android Compass through Unity 3D.’

Night Runner – Free Unity Android Game

I’ve been working on several games that require heavy use of the accelerometer functions in Android devices and while I was refining my methods I came up with a simple casual game idea. After about 6 hours of work I had “Night Runner” – a fast paced accelerometer casual game!  Since my dev time on this was really really low I decided to launch it for free (no ads or anything) in the Market Place, just so people could have something fun and simple to play.

More info here

 

Unity and Android’s GPS

Here’s something that frustrated me for about an hour. Hopefully this will help anyone else who wants to use the GPS with Unity Android since the documentation doesn’t have any examples… not to mention the answer is pretty confusing.

I’ll save you the long story and show you exactly how it’s done. The first thing we have to do is start the iPhoneSettings.StartLocationServiceUpdates function.  Yes, I know you’re on Android… you  have to use this function anyway.  Here’s a test script for you – put this javascript on your main camera and do a test build.

Continue reading 'Unity and Android’s GPS'