UnityAds Delegate problem

The documentation does a really really poor job on explaining how to set delegates. I am trying to do the following:

void Start()
{
     UnityAds.onShow += OnShow;
}

    void OnShow()
    {
    //Do stuff
    }

When building this gives me the error: “The name `UnityAds’ does not exist in the current context”.

Can anyone show me how to add a delegate to UnityAds?

Hi,

Where did you get that code from? Take a look at http://unityads.unity3d.com/help/Documentation%20for%20Publishers/Integration-Guide-for-Unity-Asset-Store which uses

Advertisement.Show(null, new ShowOptions {
    pause = true,
    resultCallback = result => {
        Debug.Log(result.ToString());
    }
});

/Rasmus

Another example (from upcoming Unity 5.2 docs), which is more in line with what you ask for:

using UnityEngine;
using UnityEngine.Advertisements;

public class UnityAdsExample : MonoBehaviour
{
  public void ShowRewardedAd()
  {
    if (Advertisement.isReady("rewardedVideoZone"))
    {
      var options = new ShowOptions { resultCallback = HandleShowResult };
      Advertisement.Show("rewardedVideoZone", options);
    }
  }

  private void HandleShowResult(ShowResult result)
  {
    switch (result)
    {
      case ShowResult.Finished:
        Debug.Log("The ad was successfully shown.");
        //
        // YOUR CODE TO REWARD THE GAMER
        // Give coins etc.
        break;
      case ShowResult.Skipped:
        Debug.Log("The ad was skipped before reaching the end.");
        break;
      case ShowResult.Failed:
        Debug.LogError("The ad failed to be shown.");
        break;
    }
  }
}

Ah, that was what I was looking for. I was assuming delegates worked the same way as with EveryPlay since the old documentation on UnityAds hinted at the existence of delegates. Thank you!

[not so offtopic]
That means Unity 5.2 will have UnityAds integrated by default?