And now, the moment we've all been waiting for: adding Unity Ads to the game so that we can finally start making some money. The concept is simple: Unity has an agreement with various other companies to display their ads, and provides an easy-to-use API to developers that allows fetching these ads from the internet. For every ad that a player interacts with (including x-ing out of it), the dev gets paid some obscenely small amount. But if you manage to get lucky, and rack up thousands of players daily...
If you're implementing ads in your own game, you should first of all be aware that there are other options, like Ad Mob, and there are a lot of comparison articles out there about which one is actually better. I decided to just stick with Unity Ads to get something in quickly and easily, but that might not be the best choice for your game. If you're implementing Unity Ads in your game, I'd once again recommend finding a video tutorial over trying to follow Unity's written documentation. The one thing you need to be aware of right off the bat, though, is that there are two ways to get the ad plugin: using the Package Manager, or using the Asset Store download. You cannot use both, or even have both sets of files in your project, or it will implode. Seriously.
There's some necessary setup in the online Unity Dev Console, including setting up a payout plan in a relatively hidden location on the site, and some setup in the (also hidden) Services tab of the editor, but the next thing I actually struggled with was the code implementation. It's pretty similar in nature to the other API callbacks so far (if you've been following along), but you have a choice between two libraries you can import: Advertisements or Monetization. According to the documentation, the latter gives you some additional options and access to things like "Event" functionality...but from a practical standpoint, in my particular case, Monetization worked while Advertisements left me staring at a blank screen instead of an ad. Anyway, if you've done everything correctly, you'll get a static test ad in the editor, a video test ad in an Android build, and a real ad once you flip all the "test" flags off everywhere you need to do so...not recommended before actually releasing your game, unless you want to get flagged for fraud.
The API also helpfully provides a callback function for when the ad has finished (where "finished" actually means that it has been x-ed out of, not just finished playing). That's your hook-in to write code to continue with the game, and you can also check to see if the ad was watched all the way through or not, so you can appropriately reward the player. In UO, I'm not going to force you to watch any ads you don't want to, but I will reward you handsomely for doing so. Unavoidable ads may provide a higher revenue stream in the long run, but they may also annoy players to the point of causing them to quit your game entirely. Anyway, I was having a problem with my screen transition bubbles animation failing to play after the ad finished, and I couldn't figure out why. It worked in all my pre-ad tests, and I was able to prove that the "finished" callback was happening when it should be, so what was the deal? In the end, I deduced that it was a problem with the Unity animator, as I remembered I had faced something similar a while ago with the very first loading animation that plays on game start. I put it on a 0.25 second delay before starting anything, and then it was able to play smoothly and without a human-perceivable delay anyway. When I did the same thing post-ad, the problem was once again magically solved.
The last thing I want to note is that there may-or-may-not be a 25 ad limit per device per day; even the Unity devs themselves have released conflicting information on this, but I had an idea that gets around this even before I learned it might be an issue. I had decided to make my own ad, a ZWOLYA GAMES ad, for Alien Cow Farm to help cross-promote. So, after holing up for a very long afternoon to create a new 15-second trailer video, I added a random chance to display my own video ad instead of the Unity-fetched one. (It will also automatically play mine when and if the limit for Unity ads has been reached.) You can check it out at https://youtu.be/ixT4n4iRhs0!
Comentarios