Reputation: 583
I'd like to give my app users a reward after they've successfully watched a chartboost ad video, but the problem is that I can't add a function to it.
Here's the line of code in the script:
public static event Action<CBLocation,int> didCompleteRewardedVideo;
Now I have no knowledge about event actions, So I thought this piece of code would do:
Chartboost.didCompleteRewardedVideo += new EventHandler(DidCompleteRewardedVideo);
And he function:
public void DidCompleteRewardedVideo(object sender, EventArgs e)
{
PlayerPrefs.SetInt("Energy", 10);
energy = 10;
energyText.text = energy.ToString();
}
But got a compile error saying they don't match. An eventHandler is probably not the same as an action event, but just to show you how I think this works.
Thanks Nick
Upvotes: 0
Views: 455
Reputation: 20764
Whe you subscribe to the event, you have to match the event signature:
public void DidCompleteRewardedVideo(CBLocation location, int x)
{
PlayerPrefs.SetInt("Energy", 10);
energy = 10;
energyText.text = energy.ToString();
}
Subscribe like this:
Chartboost.didCompleteRewardedVideo += DidCompleteRewardedVideo;
Upvotes: 1