Example #1
0
    public static bool show(string zoneId, string rewardItemKey, Dictionary <string, string> options)
    {
        if (!_adsShow && _campaignsAvailable)
        {
            if (SharedInstance)
            {
                string optionsString = parseOptionsDictionary(options);

                if (UnityAdsExternal.show(zoneId, rewardItemKey, optionsString))
                {
                    if (_adsShowDelegate != null)
                    {
                        _adsShowDelegate();
                    }

                    _adsShow             = true;
                    _savedTimeScale      = Time.timeScale;
                    _savedAudioVolume    = AudioListener.volume;
                    AudioListener.pause  = true;
                    AudioListener.volume = 0;
                    Time.timeScale       = 0;

                    return(true);
                }
            }
        }

        return(false);
    }
Example #2
0
    void OnGUI()
    {
        if (GUI.Button(new Rect(10, 10, 150, 50), _campaignsAvailable ? "Open Zone 1" : "Waiting..."))
        {
            if (_campaignsAvailable)
            {
                UnityAdsExternal.Log("Open Zone 1 -button clicked");
                UnityAds.show("16-default");
            }
        }

        if (GUI.Button(new Rect(10, 70, 150, 50), _campaignsAvailable ? "Open Zone 2" : "Waiting..."))
        {
            if (_campaignsAvailable)
            {
                UnityAdsExternal.Log("Open Zone 2 -button clicked");
                UnityAds.show("16-default", "ship", new Dictionary <string, string> {
                    { "openAnimated", "true" },
                    { "noOfferScreen", "true" },
                    { "sid", "testiSid" },
                    { "muteVideoSounds", "true" },
                    { "useDeviceOrientationForVideo", "true" }
                });
            }
        }
    }
Example #3
0
 public static void setDefaultRewardItemAsRewardItem()
 {
     if (_campaignsAvailable)
     {
         UnityAdsExternal.setDefaultRewardItemAsRewardItem();
     }
 }
Example #4
0
 public static void hide()
 {
     if (_adsShow)
     {
         UnityAdsExternal.hide();
     }
 }
Example #5
0
    public static string getCurrentRewardItemKey()
    {
        if (_campaignsAvailable)
        {
            return(UnityAdsExternal.getCurrentRewardItemKey());
        }

        return("");
    }
Example #6
0
    public static bool setRewardItemKey(string rewardItemKey)
    {
        if (_campaignsAvailable)
        {
            return(UnityAdsExternal.setRewardItemKey(rewardItemKey));
        }

        return(false);
    }
Example #7
0
    public static bool canShow()
    {
        if (_campaignsAvailable)
        {
            return(UnityAdsExternal.canShow());
        }

        return(false);
    }
Example #8
0
    public void onVideoStarted()
    {
        if (_videoStartedDelegate != null)
        {
            _videoStartedDelegate();
        }

        UnityAdsExternal.Log("onVideoStarted");
    }
Example #9
0
    public static bool hasMultipleRewardItems()
    {
        if (_campaignsAvailable)
        {
            return(UnityAdsExternal.hasMultipleRewardItems());
        }

        return(false);
    }
Example #10
0
    public void onFetchFailed()
    {
        _campaignsAvailable = false;
        if (_campaignsFetchFailedDelegate != null)
        {
            _campaignsFetchFailedDelegate();
        }

        UnityAdsExternal.Log("onFetchFailed");
    }
Example #11
0
    public void onFetchCompleted()
    {
        _campaignsAvailable = true;
        if (_campaignsAvailableDelegate != null)
        {
            _campaignsAvailableDelegate();
        }

        UnityAdsExternal.Log("onFetchCompleted");
    }
Example #12
0
    private static void fillRewardItemKeyData()
    {
        string keyData = UnityAdsExternal.getRewardItemDetailsKeys();

        if (keyData != null && keyData.Length > 2)
        {
            List <string> splittedKeyData = new List <string>(keyData.Split(';'));
            _rewardItemNameKey    = splittedKeyData.ToArray().GetValue(0).ToString();
            _rewardItemPictureKey = splittedKeyData.ToArray().GetValue(1).ToString();
        }
    }
Example #13
0
    public static List <string> getRewardItemKeys()
    {
        List <string> retList = new List <string>();

        if (_campaignsAvailable)
        {
            string keys = UnityAdsExternal.getRewardItemKeys();
            retList = new List <string>(keys.Split(';'));
        }

        return(retList);
    }
Example #14
0
    /* Events */

    public void onHide()
    {
        _adsShow             = false;
        AudioListener.pause  = false;
        AudioListener.volume = _savedAudioVolume;
        Time.timeScale       = _savedTimeScale;

        if (_adsHideDelegate != null)
        {
            _adsHideDelegate();
        }

        UnityAdsExternal.Log("onHide");
    }
Example #15
0
    public void onVideoCompleted(string parameters)
    {
        if (parameters != null)
        {
            List <string> splittedParameters = new List <string>(parameters.Split(';'));
            string        rewardItemKey      = splittedParameters.ToArray().GetValue(0).ToString();
            bool          skipped            = splittedParameters.ToArray().GetValue(1).ToString() == "true" ? true : false;

            if (_videoCompletedDelegate != null)
            {
                _videoCompletedDelegate(rewardItemKey, skipped);
            }

            UnityAdsExternal.Log("onVideoCompleted: " + rewardItemKey + " - " + skipped);
        }
    }
Example #16
0
    public static Dictionary <string, string> getRewardItemDetailsWithKey(string rewardItemKey)
    {
        Dictionary <string, string> retDict = new Dictionary <string, string>();
        string rewardItemDataString         = "";

        if (_campaignsAvailable)
        {
            rewardItemDataString = UnityAdsExternal.getRewardItemDetailsWithKey(rewardItemKey);

            if (rewardItemDataString != null)
            {
                List <string> splittedData = new List <string>(rewardItemDataString.Split(';'));
                UnityAdsExternal.Log("UnityAndroid: getRewardItemDetailsWithKey() rewardItemDataString=" + rewardItemDataString);

                if (splittedData.Count == 2)
                {
                    retDict.Add(getRewardItemNameKey(), splittedData.ToArray().GetValue(0).ToString());
                    retDict.Add(getRewardItemPictureKey(), splittedData.ToArray().GetValue(1).ToString());
                }
            }
        }

        return(retDict);
    }
Example #17
0
    /* Static Methods */

    public static bool isSupported()
    {
        return(UnityAdsExternal.isSupported());
    }
Example #18
0
 public void onShow()
 {
     UnityAdsExternal.Log("onShow");
 }
Example #19
0
 public static string getSDKVersion()
 {
     return(UnityAdsExternal.getSDKVersion());
 }