/// <summary>
        /// Triggered when rewarded video was loaded and is ready to show
        /// </summary>
        private void RewardedVideoLoaded()
        {
            if (rewardedVideoAd.IsValid())
            {
                if (debug)
                {
                    Debug.Log(this + " " + "Rewarded Video Loaded");
                    ScreenWriter.Write(this + " " + "Rewarded Video Loaded");
                }
                rewardedVideoisLoaded     = true;
                rewardedVideoDidClose     = false;
                currentRetryRewardedVideo = 0;
            }
            else
            {
                if (debug)
                {
                    Debug.Log(this + " " + "Rewarded Video Loaded but is invalid");
                    ScreenWriter.Write(this + " " + "Rewarded Video Loaded but is invalid");
                }

                //try again to load a rewarded video
                if (currentRetryRewardedVideo < maxRetryCount)
                {
                    currentRetryRewardedVideo++;
                    if (debug)
                    {
                        Debug.Log(this + " " + "RETRY " + currentRetryRewardedVideo);
                        ScreenWriter.Write(this + " " + "RETRY " + currentRetryRewardedVideo);
                    }
                    Invoke("LoadRewardedVideo", reloadTime);
                }
            }
        }
Beispiel #2
0
    private void LoadingRewardedAdSuccessful()
    {
        isRewardedLoading = false;
        isRewardedLoaded  = true;
        string isAdValid = rewardedAd.IsValid() ? "valid" : "invalid";

        StatusShow.instance.ShowAdStatus("Rewarded ad loaded and " + isAdValid);
    }
 void RewardedVideoAdDidLoad()
 {
     if (rewardedVideoAd.IsValid())
     {
         rewardedVideoAd.Show();
     }
     //Manager.LoadingAnimation(false);
 }
Beispiel #4
0
    public void LoadRewardedVideo()
    {
        statusLabel.text = "Loading rewardedVideo ad...";
        rewardedVideoAd  = new RewardedVideoAd("378297562859739_378307472858748");
        rewardedVideoAd.Register(gameObject);
        rewardedVideoAd.RewardedVideoAdDidLoad = delegate()
        {
            Debug.Log("RewardedVideo ad loaded.");
            isLoaded = true;
            didClose = false;
            string isAdValid = rewardedVideoAd.IsValid() ? "valid" : "invalid";
            statusLabel.text = "Ad loaded and is " + isAdValid + ". Click show to present!";
            rewardedVideoAd.Show();
        };

        rewardedVideoAd.RewardedVideoAdDidFailWithError = delegate(string error)
        {
            Debug.Log("RewardedVideo ad failed to load with error: " + error);
            SetStatusOrderingWindow(false);
        };

        rewardedVideoAd.RewardedVideoAdWillLogImpression = delegate()
        {
            AdGetReward();
        };

        rewardedVideoAd.RewardedVideoAdDidClick = delegate()
        {
            AdGetReward();
        };

        rewardedVideoAd.RewardedVideoAdDidFail = delegate()
        {
            Debug.Log("Rewarded video ad not validated, or no response from server");
            SetStatusOrderingWindow(false);
        };

        rewardedVideoAd.RewardedVideoAdDidClose = delegate()
        {
            Debug.Log("Rewarded video ad did close.");
            didClose = true;
            SetStatusOrderingWindow(false);
        };

        if (Application.platform == RuntimePlatform.Android)
        {
            rewardedVideoAd.RewardedVideoAdActivityDestroyed = delegate()
            {
                if (!didClose)
                {
                    Debug.Log("Rewarded video activity destroyed without being closed first.");
                    Debug.Log("Game should resume. User should not get a reward.");
                }
            };
        }
        rewardedVideoAd.LoadAd();
    }
        protected override bool DoPreLoadAd()
        {
            if (m_RewardVideoAd != null && m_RewardVideoAd.IsValid())
            {
                return(false);
            }

            if (m_RewardVideoAd == null)
            {
                m_RewardVideoAd = new RewardedVideoAd(m_Config.unitID);
                m_RewardVideoAd.Register(UIMgr.S.uiRoot.gameObject);
                m_RewardVideoAd.RewardedVideoAdDidLoad            = HandleOnAdLoaded;
                m_RewardVideoAd.RewardedVideoAdDidFailWithError  += HandleOnAdFailedToLoad;
                m_RewardVideoAd.RewardedVideoAdWillLogImpression += HandleOnAdLogImpression;
                m_RewardVideoAd.RewardedVideoAdDidClick          += HandleOnAdClick;
                m_RewardVideoAd.RewardedVideoAdDidClose          += HandleOnFBAdClose;
                m_RewardVideoAd.RewardedVideoAdComplete          += HandleOnAdComplate;
                m_RewardVideoAd.RewardedVideoAdDidSucceed        += HandleOnAdSuccess;
            }

            m_RewardVideoAd.LoadAd();

            return(true);
        }
Beispiel #6
0
    // Load button
    public void LoadRewardedVideo()
    {
        statusLabel.text = "Loading rewardedVideo ad...";

        // Create the rewarded video unit with a placement ID (generate your own on the Facebook app settings).
        // Use different ID for each ad placement in your app.
        rewardedVideoAd = new RewardedVideoAd("1091882857878164_1152806438452472");

        // For S2S validation you can create the rewarded video ad with the reward data
        // Refer to documentation here:
        // https://developers.facebook.com/docs/audience-network/android/rewarded-video#server-side-reward-validation
        // https://developers.facebook.com/docs/audience-network/ios/rewarded-video#server-side-reward-validation
        RewardData rewardData = new RewardData
        {
            UserId   = "USER_ID",
            Currency = "REWARD_ID"
        };

#pragma warning disable 0219
        RewardedVideoAd s2sRewardedVideoAd = new RewardedVideoAd("1091882857878164_1152806438452472", rewardData);
#pragma warning restore 0219

        rewardedVideoAd.Register(gameObject);

        // Set delegates to get notified on changes or when the user interacts with the ad.
        rewardedVideoAd.RewardedVideoAdDidLoad = delegate()
        {
            Debug.Log("RewardedVideo ad loaded.");
            isLoaded = true;
            didClose = false;
            string isAdValid = rewardedVideoAd.IsValid() ? "valid" : "invalid";
            statusLabel.text = "Ad loaded and is " + isAdValid + ". Click show to present!";
        };
        rewardedVideoAd.RewardedVideoAdDidFailWithError = delegate(string error)
        {
            Debug.Log("RewardedVideo ad failed to load with error: " + error);
            statusLabel.text = "RewardedVideo ad failed to load. Check console for details.";
        };
        rewardedVideoAd.RewardedVideoAdWillLogImpression = delegate()
        {
            Debug.Log("RewardedVideo ad logged impression.");
        };
        rewardedVideoAd.RewardedVideoAdDidClick = delegate()
        {
            Debug.Log("RewardedVideo ad clicked.");
        };

        // For S2S validation you need to register the following two callback
        // Refer to documentation here:
        // https://developers.facebook.com/docs/audience-network/android/rewarded-video#server-side-reward-validation
        // https://developers.facebook.com/docs/audience-network/ios/rewarded-video#server-side-reward-validation
        rewardedVideoAd.RewardedVideoAdDidSucceed = delegate()
        {
            Debug.Log("Rewarded video ad validated by server");
        };

        rewardedVideoAd.RewardedVideoAdDidFail = delegate()
        {
            Debug.Log("Rewarded video ad not validated, or no response from server");
        };

        rewardedVideoAd.RewardedVideoAdDidClose = delegate()
        {
            Debug.Log("Rewarded video ad did close.");
            didClose = true;
            if (rewardedVideoAd != null)
            {
                rewardedVideoAd.Dispose();
            }
        };

#if UNITY_ANDROID
        /*
         * Only relevant to Android.
         * This callback will only be triggered if the Rewarded Video activity
         * has been destroyed without being properly closed. This can happen if
         * an app with launchMode:singleTask (such as a Unity game) goes to
         * background and is then relaunched by tapping the icon.
         */
        rewardedVideoAd.RewardedVideoAdActivityDestroyed = delegate()
        {
            if (!didClose)
            {
                Debug.Log("Rewarded video activity destroyed without being closed first.");
                Debug.Log("Game should resume. User should not get a reward.");
            }
        };
#endif

        // Initiate the request to load the ad.
        rewardedVideoAd.LoadAd();
    }