Exemple #1
0
    // Use this for initialization
    public override void Start()
    {
        base.Start();

        Debug.Log("Start() => " + gameObject.name);

        adList = new List <NendAd> ();

        NendAdBanner banner = NendUtils.GetBannerComponent(bannerGameObject);

        adList.Add(banner);

        banner.AdLoaded           += OnFinishLoadBannerAd;
        banner.AdReceived         += OnReceiveBannerAd;
        banner.AdFailedToReceive  += OnFailToReceiveBannerAd;
        banner.AdClicked          += OnClickBannerAd;
        banner.AdBacked           += OnDismissScreen;
        banner.InformationClicked += OnClickBannerInformation;

#if UNITY_ANDROID
        NendAdIcon icon = NendUtils.GetIconComponent(iconGameObject);
        adList.Add(icon);

        icon.AdLoaded           += OnFinishLoadIconAd;
        icon.AdReceived         += OnReceiveIconAd;
        icon.AdFailedToReceive  += OnFailToReceiveIconAd;
        icon.AdClicked          += OnClickIconAd;
        icon.InformationClicked += OnClickIconInformation;
#endif

        RegisterAction("Next", delegate() {
            LoadScene("Second");
        });
        RegisterAction("BannerLayout", delegate() {
            LoadScene("Banner");
        });
#if UNITY_ANDROID
        RegisterAction("IconLayout", delegate() {
            LoadScene("Icon");
        });
#endif
        RegisterAction("NativeAd", delegate() {
            LoadScene("Menu");
        });
        RegisterAction("FullBoard", delegate() {
            LoadScene("FullBoard");
        });
        RegisterAction("Quit", delegate() {
            Application.Quit();
        });

        if (isResumeNeeded)
        {
            foreach (NendAd ad in adList)
            {
                ShowAd(ad);
            }
            isResumeNeeded = false;
        }
    }
    void Awake()
    {
        UnityEngine.Debug.Log("Awake() => " + gameObject.name);
        banner = NendUtils.GetBannerComponent(bannerGameObject);

        // attach EventHandlers
        NendAdInterstitial.Instance.AdLoaded  += OnFinishLoadInterstitialAd;
        NendAdInterstitial.Instance.AdShown   += OnShowInterstitialAd;
        NendAdInterstitial.Instance.AdClicked += OnClickInterstitialAd;
    }
    // Use this for initialization
    public override void Start()
    {
        base.Start();

        banner = NendUtils.GetBannerComponent("NendAdBanner3");

        RegisterAction("Back", delegate() {
            banner.Destroy();
            SceneManager.LoadScene("First");
        });
        RegisterAction("Show", delegate() {
            ShowAd(banner);
        });
        RegisterAction("Hide", delegate() {
            HideAd(banner);
        });
        RegisterAction("CenterTop", delegate() {
            banner.Layout(new NendAdDefaultLayoutBuilder().Gravity((int)Gravity.TOP | (int)Gravity.CENTER_HORIZONTAL));
        });
        RegisterAction("CenterBottom", delegate() {
            banner.Layout(new NendAdDefaultLayoutBuilder().Gravity((int)Gravity.BOTTOM | (int)Gravity.CENTER_HORIZONTAL));
        });
        RegisterAction("UpperLeft", delegate() {
            banner.Layout(new NendAdDefaultLayoutBuilder().Gravity((int)Gravity.TOP | (int)Gravity.LEFT));
        });
        RegisterAction("UpperRight", delegate() {
            banner.Layout(new NendAdDefaultLayoutBuilder().Gravity((int)Gravity.TOP | (int)Gravity.RIGHT));
        });
        RegisterAction("LowerLeft", delegate() {
            banner.Layout(new NendAdDefaultLayoutBuilder().Gravity((int)Gravity.BOTTOM | (int)Gravity.LEFT));
        });
        RegisterAction("LowerRight", delegate() {
            banner.Layout(new NendAdDefaultLayoutBuilder().Gravity((int)Gravity.BOTTOM | (int)Gravity.RIGHT));
        });
        RegisterAction("Center", delegate() {
            banner.Layout(new NendAdDefaultLayoutBuilder().Gravity((int)Gravity.CENTER_HORIZONTAL | (int)Gravity.CENTER_VERTICAL));
        });
        RegisterAction("CenterLeft", delegate() {
            banner.Layout(new NendAdDefaultLayoutBuilder().Gravity((int)Gravity.CENTER_VERTICAL | (int)Gravity.LEFT));
        });
        RegisterAction("CenterRight", delegate() {
            banner.Layout(new NendAdDefaultLayoutBuilder().Gravity((int)Gravity.CENTER_VERTICAL | (int)Gravity.RIGHT));
        });
        RegisterAction("UpperLeftWithClearance", delegate() {
            banner.Layout(new NendAdDefaultLayoutBuilder()
                          .MarginLeft(16)
                          .MarginTop(16));
        });
#if UNITY_ANDROID
        RegisterAction("UpperLeftWithClearancePx", delegate() {
            banner.Layout(new NendAdDefaultLayoutBuilder()
                          .Unit(ComplexUnit.PX)
                          .MarginLeft(16)
                          .MarginTop(16));
        });
#endif
        RegisterAction("LowerRightWithClearance", delegate() {
            banner.Layout(new NendAdDefaultLayoutBuilder()
                          .Gravity((int)Gravity.RIGHT | (int)Gravity.BOTTOM)
                          .MarginRight(16)
                          .MarginBottom(16));
        });
#if UNITY_ANDROID
        RegisterAction("LowerRightWithClearancePx", delegate() {
            banner.Layout(new NendAdDefaultLayoutBuilder()
                          .Gravity((int)Gravity.RIGHT | (int)Gravity.BOTTOM)
                          .Unit(ComplexUnit.PX)
                          .MarginRight(16)
                          .MarginBottom(16));
        });
#endif
        RegisterAction("CenterTopWithClearance", delegate() {
            banner.Layout(new NendAdDefaultLayoutBuilder()
                          .Gravity((int)Gravity.CENTER_HORIZONTAL | (int)Gravity.TOP)
                          .MarginTop(16));
        });
#if UNITY_ANDROID
        RegisterAction("CenterTopWithClearancePx", delegate() {
            banner.Layout(new NendAdDefaultLayoutBuilder()
                          .Gravity((int)Gravity.CENTER_HORIZONTAL | (int)Gravity.TOP)
                          .Unit(ComplexUnit.PX)
                          .MarginTop(16));
        });
#endif
        RegisterAction("CenterLeftWithClearance", delegate() {
            banner.Layout(new NendAdDefaultLayoutBuilder()
                          .Gravity((int)Gravity.CENTER_VERTICAL | (int)Gravity.LEFT)
                          .MarginLeft(16));
        });
        RegisterAction("CenterRightWithClearance", delegate() {
            banner.Layout(new NendAdDefaultLayoutBuilder()
                          .Gravity((int)Gravity.CENTER_VERTICAL | (int)Gravity.RIGHT)
                          .MarginRight(16));
        });
        RegisterAction("CenterBottomWithClearance", delegate() {
            banner.Layout(new NendAdDefaultLayoutBuilder()
                          .Gravity((int)Gravity.CENTER_HORIZONTAL | (int)Gravity.BOTTOM)
                          .MarginBottom(16));
        });
#if UNITY_ANDROID
        RegisterAction("CenterBottomWithClearancePx", delegate() {
            banner.Layout(new NendAdDefaultLayoutBuilder()
                          .Gravity((int)Gravity.CENTER_HORIZONTAL | (int)Gravity.BOTTOM)
                          .Unit(ComplexUnit.PX)
                          .MarginBottom(16));
        });
#endif
    }