So if we open up our app, initialize script, and we go down to our show Add button here, what we need to do is we need to we can get rid of this. We don't need that anymore, because we know it works. And let's go over to unity quickstart guide. Okay, what do we need to grab from him? Cool. So we'll see here they have the public void show rewarded ad.
And they just have one if statement in here. You can see they use a different style of coding than I currently do with the they put these down here and up there. That's just personal preference, it doesn't actually affect the code. If we press copy, and go over to code. We can just dump that in there. I think we can actually get rid of this as well.
So now it's throwing an area here. But let's go back over to our script here. And we'll see if we got a problem. void handles show results, which is the same thing that was being underlined. So let's just copy all of this. Leave it the last one, the last curly brace, because that'll be the class.
Copy that. And let's throw that under here. Now I'm just going to fix this up to be how I like it. Cool. So that looks pretty good to me. I think that is good.
Let's press save. Let's go over to unity. Because we've just copied some code from somewhere else. We just want to press play. And just make sure we get no errors. Awesome.
We're getting our errors in we see we get this unity ads initialized equals true here. So that's good. And that's just showing that things are working. Well. If it says true, it says that things are working. And here we want to say your code reward Gamma goes, Hey, good coins, etc.
Cool. So don't need that. And then we can just say, has seen reward lab equals true. So just so everyone knows a switch statement is very much like an if statement. But it's just switching through the results. And when it lands in our result, it doesn't continue and ask the next set of questions.
So it's a little little bit more. It's a little bit more friendly for like mobiles. And all it's a little bit less work for the computer because they're quicker than if statements as far as the CPU is concerned, but they're very much the same. But all you need to worry about is putting your code in between this section here. So we've got a few cases we've got case sure results equals finished. So if we've finished the ad, the ad it'll debug dot log, the ad has been shown, we turn the rules to true, and then it breaks out so it goes all right, we break out of this and we just exit this method here.
Cool. If you've skipped the ad, well, nothing happens. But you could put some code in underneath this. But nothing happens just as I was before the end, okay? And then it breaks out of that. Or if it's failed to show like, let's say you've had an incident problem or something, nothing happens to the debugs, and logs and error and says the ad has been failed to show and then a breakdown of that.
So the one that's going to happen the most is at the top here, and we want the end. So it'll hopefully come to this, the air will be shown successfully all the way through and then it'll break out of the the switch statement. So if that's a little bit overwhelming, you don't understand that's fine. We need to remember is stuff that goes in between this break and this case, dot finished is the code that will be run. So what's the next thing that we want to do? All we need to do is it keeps trying to format like that, so let's just leave it start corrupting stop game.
We want to pass the the time as let's say 1.5 seconds. So 1.5 is cool. And I'm just gonna neaten this up a little bit. I hate copying other people's code. I guess that's how they're supposed to be formatted. But who knows, doesn't matter.
It doesn't affect the game. That looks fine to me. So now if we go over to our game, and we press play, you can see over here and out enable test mode is on. We can press play. Bam, press the hump. This screen would be your ad unit.
Awesome. So it's working perfectly fine. Press the close button when it's 1.5 seconds, and it continues on and we compress it. Fantastic. So that is now a functioning unity ads system. And the last little thing we need to do is set some cool animations and make it more enticing for the player to press the hot button.
See you in the next episode.