public static void onNativeRequestResponse(TraxnetNativeBannerAd result) { #if UNITY_ANDROID && !UNITY_EDITOR string zoneId = result.zoneId; if (result != null) { if (mMonoBehaviour != null && mMonoBehaviour.isActiveAndEnabled) { mMonoBehaviour.StartCoroutine(loadNativeBannerAdImages(result)); } else { if (errorPool.ContainsKey(zoneId)) { TraxnetError error = new TraxnetError(); error.zoneId = zoneId; error.message = "Invalid MonoBehaviour Object"; errorPool[zoneId] (error); } } } else { if (requestErrorPool.ContainsKey(zoneId)) { TraxnetError error = new TraxnetError(); error.zoneId = zoneId; error.message = "Invalid Result"; errorPool[zoneId] (error); } } #endif }
static IEnumerator loadNativeBannerAdImages(TraxnetNativeBannerAd result) { if (result.iconUrl != null && !result.iconUrl.Equals("")) { UnityWebRequest wwwIcon = UnityWebRequestTexture.GetTexture(result.iconUrl); yield return(wwwIcon.SendWebRequest()); if (wwwIcon.isNetworkError || wwwIcon.isHttpError) { Debug.Log(wwwIcon.error); } else { result.iconImage = ((DownloadHandlerTexture)wwwIcon.downloadHandler).texture; } } if (result.portraitStaticImageUrl != null && !result.portraitStaticImageUrl.Equals("")) { UnityWebRequest wwwPortrait = UnityWebRequestTexture.GetTexture(result.portraitStaticImageUrl); yield return(wwwPortrait.SendWebRequest()); if (wwwPortrait.isNetworkError || wwwPortrait.isHttpError) { Debug.Log(wwwPortrait.error); } else { result.portraitBannerImage = ((DownloadHandlerTexture)wwwPortrait.downloadHandler).texture; } } if (result.landscapeStaticImageUrl != null && !result.landscapeStaticImageUrl.Equals("")) { UnityWebRequest wwwLandscape = UnityWebRequestTexture.GetTexture(result.landscapeStaticImageUrl); yield return(wwwLandscape.SendWebRequest()); if (wwwLandscape.isNetworkError || wwwLandscape.isHttpError) { Debug.Log(wwwLandscape.error); } else { result.landscapeBannerImage = ((DownloadHandlerTexture)wwwLandscape.downloadHandler).texture; } } if (nativeBannerResponsePool.ContainsKey(result.zoneId)) { nativeBannerResponsePool[result.zoneId] (result); } }