void OnGetBannerDetails(string errorString, BannerDetail result, params object[] userParam)
    {
        if (string.IsNullOrEmpty(errorString))
        {
            if (result != null)
            {
                string InterstitialSavePath = Path.Combine(Application.persistentDataPath, result.LeaderboardId + "_Interstitial.png");
                string BannerSavePath = Path.Combine(Application.persistentDataPath, result.LeaderboardId + "_Banner.png");
                string InterstitialUrlSaveName = result.LeaderboardId + "_Interstitial";
                string BannerUrlSaveName = result.LeaderboardId + "_Banner";

                if (!File.Exists(InterstitialSavePath))
                {
                    if (UIStateManager.Manager.GameOrientation == GameOrientation.Landscape)
                    {
                        Texture2D adTexture = new Texture2D(960, 640);
                        UIStateManager.Manager.StartCoroutine(UIStateManager.Manager.SetAdBanner(result.InterstitialLandscapeUrl, InterstitialUrlSaveName, adTexture, InterstitialSavePath, result.InterstitialClickUrl));
                    }
                    else if (UIStateManager.Manager.GameOrientation == GameOrientation.Portrait)
                    {
                        Texture2D adTexture = new Texture2D(640, 960);
                        UIStateManager.Manager.StartCoroutine(UIStateManager.Manager.SetAdBanner(result.InterstitialPotraitUrl, InterstitialUrlSaveName, adTexture, InterstitialSavePath, result.InterstitialClickUrl));
                    }
                    else
                    {
                        Texture2D adTexture = new Texture2D(960, 640);
                        UIStateManager.Manager.StartCoroutine(UIStateManager.Manager.SetAdBanner(result.InterstitialLandscapeUrl, InterstitialUrlSaveName, adTexture, InterstitialSavePath, result.InterstitialClickUrl));
                    }
                }
                if (!File.Exists(BannerSavePath))
                {
                    Texture2D BannerTexture = new Texture2D(320, 50);
                    UIStateManager.Manager.StartCoroutine(UIStateManager.Manager.SetAdBanner(result.BannerUrl, BannerUrlSaveName, BannerTexture, BannerSavePath, result.BannerClickUrl));
                }
                StartCoroutine(WaitAndLoadGame());
                UIStateManager.Manager.SetLoading(false);
            }
        }
    }
Example #2
0
 BannerDetail ToBannerDetail(XmlNode node, ref string errorString)
 {
     try
     {
         BannerDetail banner = null;
         if (node != null && !string.IsNullOrEmpty(node.InnerXml))
         {
             banner = new BannerDetail();
             banner.BannerUrl = node["BannerUrl"].InnerText;
             banner.BannerCategoryType = node["BannerCategoryType"].InnerText;
             banner.BannerHeight = node["BannerHeight"].InnerText;
             banner.BannerWidth = node["BannerWidth"].InnerText;
             banner.BannerClickUrl = node["BannerClickUrl"].InnerText;
             banner.LeaderboardId = node["LeaderboardId"].InnerText;
             banner.InterstitialClickUrl = node["InterstitialClickUrl"].InnerText;
             banner.InterstitialLandscapeUrl = node["InterstitialLandscapeUrl"].InnerText;
             banner.InterstitialPotraitUrl = node["InterstitialPotraitUrl"].InnerText;
             return banner;
         }
     }
     catch (Exception ex)
     {
         errorString = ex.Message;
     }
     return null;
 }
    static void OnGetBannerDetails(string errorString, BannerDetail result, params object[] userParam)
    {
        RawImage bannerArea = userParam[0] as RawImage;
        if (bannerArea.gameObject != null)
        {
            bannerArea.gameObject.SetActive(false);
        }

        UIStateManager.Manager.SettingsSystem.AddToLeaderboardCache(
            UIStateManager.Manager.PlayerId,
            UIStateManager.Manager.CurrentLeaderboardDetail,
            UIStateManager.Manager.CurrentActivationKey,
            false);

        if (string.IsNullOrEmpty(errorString))
        {
            if (result != null)
            {
                if (bannerArea.gameObject != null)
                    bannerArea.gameObject.SetActive(true);

                UIStateManager.Manager.StartCoroutine(UIStateManager.Manager.SetBannerImage(result.BannerUrl, bannerArea));

                Button button = bannerArea.gameObject.GetComponent<Button>();
                button.onClick.RemoveAllListeners();

                if (!string.IsNullOrEmpty(result.BannerClickUrl))
                {
                    button.interactable = true;
                    button.onClick.AddListener(() =>
                    {
                        Application.OpenURL(result.BannerClickUrl);
                    });
                }
                else
                {
                    button.interactable = false;
                }
            }
        }
    }