Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Overlaying Reward Grfx for Click-Thrus

Discussion in 'Unity Ads & User Acquisition' started by ippdev, Oct 8, 2014.

  1. ippdev

    ippdev

    Joined:
    Feb 7, 2010
    Posts:
    3,850
    I followed one of couple of instruction sets for integrating UnityAds. In the Asset Store downloads there is reference to a prefab that you can set values in. The download does not have any prefab objects. So I dug around some more and took this from the quickstart guide. I initialize it in Start and then every time the player dies and returns to the MainMenu I call ShowTheAdvert(). Is that really all there is to it?

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using UnityEngine.Advertisements;
    4.  
    5. public class AdInitialization : MonoBehaviour {
    6.  
    7.     void Start() {
    8.         Advertisement.Initialize("GAMEID#");
    9.     }
    10.    
    11.     void ShowTheAdvert () {
    12.         if (Advertisement.isReady()) {
    13.             Advertisement.Show();
    14.         }
    15.     }
    16. }
    The client wants to overlay a grfx offering coins for cllick-throughs and viewing. Also, what determines that a player has clicked through so his reward can be added? The documentation is sparse and any explanation of how this would be done would be handy to document for more than just myself.

    I want to hand this off to the client so he can do device testing and uploading to his account. Once I get his click thru reward grfx reliably overlaid I can deliver him the goods. Also..are there any gotchas I should be aware of so when this leaves my desk i won't be seeing it for bug fixing or errors..as far as UnityAds go.
     
  2. unity-nikkolai

    unity-nikkolai

    Joined:
    Sep 18, 2014
    Posts:
    540
    Sounds like you landed on the deprecated integration guide for Unity (noted at the top of the page). There's a new integration guide for the current version of the Asset Store package, which does not include a prefab. Sorry about the confusion. We are in the process of revising and revamping our documentation. For now, you want to be referring to the Integration Guide for Unity Asset Store Package.

    There is an example script in the guide. I've also written a couple additional examples with commenting:
    What you have looks good, and will basically get the job done. To award users, you can use the isReady() method to first make sure ads are available and ready to be shown. If it returns true, you can setup your offer screen—basically just offering a reward if they choose to completely watch a video ad—which you would design and implement to match the look and feel of your game. Once the user has accepted the offer, you can call Show().

    In order to deliver the goods, you need to pass a new ShowOptions object as a second parameter when calling Show(). There you can define a callback method to handle the callback result (Finished, Skipped, or Failed to show). You can find an example of this in the Basic Unity Ads Demo script.

    The only gotchas to be aware of when designing your game is that ads are not guaranteed. In order for isReady() to return true, there need to be ad campaigns available for the region the user is in. (Advertisers decide which regions their campaigns will be available to.) There is also a one hour cool-down on ads. A user should not be able to see the same ad twice in one hour. If they've watched all available campaigns available to their region in under an hour, they won't see another ad until after the cool-down. There is also a mediation algorithm in place for users that limits the number of ads they see per day per game based on a number of variables. On top of all this, there is also a hard ceiling limit of 25 ads per day per user per game. The intention of this is to prevent from over saturating users with ads.
     
  3. ippdev

    ippdev

    Joined:
    Feb 7, 2010
    Posts:
    3,850
    Thanks for the reply. I will go over the documentation linked. Alot of the examples use he old GUI system. Is there going to be uGUI examples coming shortly? And howzabout some UnityScript examples as well? I come from a 10+ year background of ActionScript coding and can code like 5X quicker in UnityScript as i rarely have to look at the API and C# is like talking like Yoda to me whereas UnityScript is in my native tongue so to speak..I also do not get the namespace stuff so I cannot just rehack the scripts to my framework. I have implemented callbacks in US from C# plugins prior but do not remember exactly. I think it was
    Code (JavaScript):
    1. var _callBack : function;
    2.  
    3. function MyCallBack (_callBack : function) {
    4.         //handle callBack code
    5. }
    Does this look correct for handling callbacks from C# in US?

    Again..thank you for your prompt reply. I figure if we can get enough issues out there in forum replies to this and that issue that it will be easier on future devs. Unity js, uGUI and callbacks I will bet will have many users flummoxed when trying to implement the examples.
     
    Last edited: Oct 9, 2014
    Orimay likes this.
  4. unity-nikkolai

    unity-nikkolai

    Joined:
    Sep 18, 2014
    Posts:
    540
    An example with the new Unity GUI is a great idea! Possibly a project for tonight.

    As for UnityScript, documentation for Unity as a whole is beginning to move toward prioritizing C# over UnityScript. And being that all of the wrapper code for the Unity Ads SDK found in the asset package is written in C#, we naturally defaulted to just making examples in C#. Haven't seen all that many requests come in for examples in UnityScript. Soon though, I'll be cooking up UnityScript equivalents of the current C# examples for all the ECMA based folks.

    Not sure about the proper syntax for callbacks in Javascript. I'll have to look it up and test to make sure it works first.
     
  5. ippdev

    ippdev

    Joined:
    Feb 7, 2010
    Posts:
    3,850
    Thanks Nikkolai. C# may have brought a boatload of devs onboard to Unity but I can say from experience as a former AS/ECMA dev that the structure of UNITY .js was what made me drop Flash like a hot potato and commit to developing in Unity full time back in 2009 and I have several thousand scripts and several dozen frameworks in UnityScript..so I am not too keen on switching and writing those framework from scratch and replacing hundreds of helper scripts. I look forward to the examples. Don't make us js devs the bastard children of Unity.
     
  6. unity-nikkolai

    unity-nikkolai

    Joined:
    Sep 18, 2014
    Posts:
    540
    I hear ya man. That's what got me into using Unity, too. UnityScript was the front runner for so long just for that reason. As that blog post I shared shows though, there's definitely a change in the winds. A lot more people are using C# over UnityScript with Unity, and there are a lot of reasons for it. As a result, Unity's documentation team is refocusing their efforts. Boo is being dropped as a supported language in Unity 5.0. However, UnityScript, even if it isn't #1 anymore, will continue to be supported—just with C# taking the lead this time around.
     
  7. unity-nikkolai

    unity-nikkolai

    Joined:
    Sep 18, 2014
    Posts:
    540
    The latest version of the Unity Ads asset package (1.0.3) released last week, and is more UnityScript friendly than previous versions. Unity Ads script assets are placed within the Standard Assets directory so that they compile before your UnityScript assets, allowing them to reference from the C# scripts.

    I've written a UnityScript version of the UnityAdsHelper script called UnityAdsHelperJS, which handles much of the integration for Unity Ads. Feel free to use it in your projects and modify it to fit your needs. I've also written a UnityScript version of a button example called UnityAdsButtonJS to show how you might use it within your own game code.
     
  8. Orimay

    Orimay

    Joined:
    Nov 16, 2012
    Posts:
    304
    Is there an uGUI version yet?
     
  9. unity-nikkolai

    unity-nikkolai

    Joined:
    Sep 18, 2014
    Posts:
    540