Beispiel #1
0
        public void Show(string zoneId = null, ShowOptions options = null)
        {
            string gamerSid = null;

            _resultDelivered = false;

            if (options != null)
            {
                if (options.resultCallback != null)
                {
                    resultCallback = options.resultCallback;
                }

                // Disable obsolete method warnings for this piece of code because here we need to access legacy ShowOptionsExtended to maintain compability
#pragma warning disable 612, 618
                ShowOptionsExtended extendedOptions = options as ShowOptionsExtended;
                if (extendedOptions != null && extendedOptions.gamerSid != null && extendedOptions.gamerSid.Length > 0)
                {
                    gamerSid = extendedOptions.gamerSid;
                }
                else
                {
                    gamerSid = options.gamerSid;
                }
#pragma warning restore 612, 618
            }

            if (!isInitialized || isShowing)
            {
                deliverCallback(ShowResult.Failed);
                return;
            }

            if (gamerSid != null)
            {
                if (!show(zoneId, "", new Dictionary <string, string> {
                    { "sid", gamerSid }
                }))
                {
                    deliverCallback(ShowResult.Failed);
                }
            }
            else
            {
                if (!show(zoneId))
                {
                    deliverCallback(ShowResult.Failed);
                }
            }
        }
        public override void Show(string zoneId, string adapterId, ShowOptions options = null)
        {
            if (options != null && options.pause == false)
            {
                Utils.LogWarning("Video ads will always pause engine, ignoring pause=false in ShowOptions");
            }

            Dictionary <string, object> configuration = _configurations[zoneId + adapterId];

            if (configuration != null && configuration.ContainsKey("network"))
            {
                UnityAds.setNetwork((string)configuration["network"]);
            }
            string videoZoneId = null;
            string rewardItem  = "";

            if (configuration != null && configuration.ContainsKey("zone"))
            {
                videoZoneId = (string)configuration["zone"];
            }
            if (configuration != null && configuration.ContainsKey("rewardItem"))
            {
                rewardItem = (string)configuration["rewardItem"];
            }

            UnityAds.OnShow           += UnityAdsShow;
            UnityAds.OnHide           += UnityAdsHide;
            UnityAds.OnVideoCompleted += UnityAdsVideoCompleted;
            UnityAds.OnVideoStarted   += UnityAdsVideoStarted;

            ShowOptionsExtended extendedOptions = options as ShowOptionsExtended;

            if (extendedOptions != null && extendedOptions.gamerSid != null && extendedOptions.gamerSid.Length > 0)
            {
                if (!UnityAds.show(videoZoneId, rewardItem, new Dictionary <string, string>()
                {
                    { "sid", extendedOptions.gamerSid }
                }))
                {
                    triggerEvent(EventType.error, EventArgs.Empty);
                }
            }
            else
            {
                if (!UnityAds.show(videoZoneId, rewardItem))
                {
                    triggerEvent(EventType.error, EventArgs.Empty);
                }
            }
        }
Beispiel #3
0
        public void Show(string zoneId = null, ShowOptions options = null)
        {
            string gamerSid = null;

            _resultDelivered = false;

            if (options != null)
            {
                if (options.resultCallback != null)
                {
                    resultCallback = options.resultCallback;
                }

                ShowOptionsExtended extendedOptions = options as ShowOptionsExtended;
                if (extendedOptions != null && extendedOptions.gamerSid != null && extendedOptions.gamerSid.Length > 0)
                {
                    gamerSid = extendedOptions.gamerSid;
                }
            }

            if (!isInitialized || isShowing)
            {
                deliverCallback(ShowResult.Failed);
                return;
            }

            if (gamerSid != null)
            {
                if (!show(zoneId, "", new Dictionary <string, string> {
                    { "sid", gamerSid }
                }))
                {
                    deliverCallback(ShowResult.Failed);
                }
            }
            else
            {
                if (!show(zoneId))
                {
                    deliverCallback(ShowResult.Failed);
                }
            }
        }