Monthly Archives: June 2015

Annoying Unity3D Omission with iOS Banner Ads

So, Unity provides a nice and easy to use wrapper for iOS banner ads.  This is great and I use it in my ad mediator code (I don’t trust 3rd party mediators… had issues with them all).  Unfortunately, in their wisdom, they left out one little thing… there is no call back when a iAd doesn’t load, so you get a lovely blank ad space – earning you slightly less money than an actual iAd would.

-(void)bannerView:(ADBannerView*)banner didFailToReceiveAdWithError:(NSError*)error
    ::printf_console("ADBannerView error: %s\n", [[error localizedDescription] UTF8String]);
    _showingBanner = NO;
    [self layoutBannerImpl];

That’s the code they have in when you build an iOS project.

With the simple addition of one line you can get a notification that the ad failed to load and then present another ad from another provider.

-(void)bannerView:(ADBannerView*)banner didFailToReceiveAdWithError:(NSError*)error
    ::printf_console("ADBannerView error: %s\n", [[error localizedDescription] UTF8String]);
    _showingBanner = NO;
    UnityADBannerViewWasLoaded(); // Added by CG
    [self layoutBannerImpl];

As you can see, I just fire the existing notification system they already have.  The triggered callback just checks to see if _showingBanner is set to ‘NO’ and if it is, then it signifies that no ad was loaded – simple right?

Unfortunately, I have to update this line every time I ‘Replace’ or build a new iOS App – you wouldn’t believe the number of times I’ve forgotten… or maybe you would.

Pretty simple for the folks at Unity to include this in their iOS project template, and they’ve been asked to do so by many different developers, but nothing yet.

Thank You Amazon!

I’d pushed an Android version of my Candy Bubble Drop app to the Amazon App store on Friday, and luckily for me they found a bug in my logic that resulted in the player being able to spend gems they didn’t have!

While this is annoying, and counter to the consumable purchase plan, it wasn’t until I explored further that I realized that having a negative number of gems actually stopped the game from working correctly – oops.

Anyway, I’ve fixed the bug (all my fault) and uploaded the new versions to GooglePlay and the Amazon App Store.  However, just wanted to give out some props to Amazon for actually testing their submissions.

(And the above link reminds me I need to update our own webpage)

Candy Bubble Drop – YouTube video

Posted a short video to YouTube of Candy Bubble Drop in action.  This was recorded with QuickTime for the Mac using an iPad as a video source.

This was done so I can use it in the Android Console.  It will then be available to anyone browsing the App in the Google Play Store.  Of course, typical Google, when you upload a video to YouTube, they give you a handy short link.  The Google Play Store Console doesn’t recognize this Google provided short link as a valid YouTube link… go figure.

GameCenter on iOS Observation

I’ve been working on making an Ad Free version of my Candy Bubble Drop game and decided to use the GameCenter grouped Leaderboards & Achievements so both versions will share them.

This is pretty simple to setup in iTunesConnect, however (and why would I expect anything different) I ran into an issue with the way I had my Leaderboards & Achievements setup.

For the free version, I’d used ‘.Zone1’ as a Leaderboard ID and ‘.Zone1’ as an achievement ID.  The Leaderboard is used to record the best scores from Zone1 and the achievement is set when the player completes all the levels in Zone1.  Even though they have exactly the same ID, this never caused a problem, and I think I’ve done something like this in other Apps.

When I came to make a GameCenter Group, it updates all the IDs by prefixing them with ‘grp.’ and it wouldn’t accept that a Leaderboard and an Achievement have the same ID.  I modified the group achievement IDs, but now I need to code up a hack to modify the ID I submit to match the one I entered in GameCenter.

Morale of the story — DON’T use the same identifier for Leaderboards & Achievements in GameCenter, it might work just fine, but if you ever decide to group it with another App, then you’ll have to end up hacking your code to allow for a different ID.

Learning C# Syntax

I was never ‘taught’ c# – I’ve grown into it from other languages and there are certain nuances and quirky syntax that I might have read/seen at one point or another, but forgotten.  It’s with that in mind that I’m sharing this recent ‘discovery’ by me.

C# has a ?? operator.  It’s kind of like the standard conditional operator ?: but is specifically setup as a null check shortcut.

These two sections of code are functionally equivalent

	parentToggle = gameObject.GetComponent();
	if (parentToggle==null)
		parentToggle = gameObject.GetComponentInParent();
	parentToggle = gameObject.GetComponent() ?? gameObject.GetComponentInParent();

In other words, ‘arg1 ?? arg2’ is the same as saying return arg1, unless arg1 == null in which case return arg2.

You could also use ‘arg1!=null?arg2:arg1’ but the ?? pattern is less typing 🙂