Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

appodeal unity integration

using UnityEngine;
using AppodealAds.Unity.Api;
using AppodealAds.Unity.Common;

public class AdManager : MonoBehaviour, IRewardedVideoAdListener {

    int timesTriedToShowInterstitial = 0;

	// Use this for initialization
	void Start () {
        string appKey = "Put your app key here.";
        Appodeal.disableLocationPermissionCheck();
        Appodeal.setTesting(true);
        Appodeal.initialize(appKey, Appodeal.INTERSTITIAL | Appodeal.BANNER | Appodeal.REWARDED_VIDEO);
        Appodeal.setRewardedVideoCallbacks(this);
    }

    public void ShowBanner()
    {
        if (Appodeal.isLoaded(Appodeal.BANNER))
            Appodeal.show(Appodeal.BANNER_TOP);
    }
    public void HideBanner()
    {
        Appodeal.hide(Appodeal.BANNER);
    }

    public void ShowInterstitial()
    {
        timesTriedToShowInterstitial++;
        if (Appodeal.isLoaded(Appodeal.INTERSTITIAL) && timesTriedToShowInterstitial >= 5)
        {
            Appodeal.show(Appodeal.INTERSTITIAL);
            timesTriedToShowInterstitial = 0;
        }
    }

    public void ShowRewarded()
    {
        if (Appodeal.isLoaded(Appodeal.REWARDED_VIDEO))
            Appodeal.show(Appodeal.REWARDED_VIDEO);
    }

    public void onRewardedVideoLoaded() { }
    public void onRewardedVideoFailedToLoad() { }
    public void onRewardedVideoShown() { }
    public void onRewardedVideoClosed() { }
    public void onRewardedVideoFinished(int amount, string name) { ManagerScript.Instance.Coins++; }
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: player ToJson unity 
Csharp :: c# get digits from int 
Csharp :: c# array accessor 
Csharp :: unity gamemanager instance not set to an instance of an object 
Csharp :: copy properties from two subclasses c# 
Csharp :: c# copy each property 
Csharp :: windows forms tablelayoutpanel scroll 
Csharp :: vb.net array search 
Csharp :: publish web app to linux or ubuntu 
Csharp :: c# decimal 
Csharp :: custom vs code snippet 
Csharp :: unity int to bool 
Csharp :: c# only only 2 digits after decimal number double 
Csharp :: unity NetworkBehaviour the type or namespace could not be found 
Csharp :: c# loop example 
Csharp :: unity3d sort list 
Csharp :: run as administrator vs 2019 
Csharp :: Select records that does not exist in another table in Entity Framework 
Csharp :: how disable the back off a panel C# 
Csharp :: RadioButton IsChecked mapped to ENum xmal 
Html :: html meta refresh 
Html :: how to change a favicon in html 
Html :: font awesome linkedin 
Html :: autoredirect html 
Html :: bootstrap a link disabled 
Html :: rails add favicon 
Html :: TypeError: Illegal invocation 
Html :: font awesome reload icon 
Html :: google web fonts open sans 
Html :: auto update copyright year javascript 
ADD CONTENT
Topic
Content
Source link
Name
6+7 =