internal static IEnumerator LoadTexture(string url, Action <Texture2D> callback) { Texture2D texture = TextureCache.Instance.Get(url); if (null != texture) { callback(texture); yield break; } #if UNITY_2019_1_OR_NEWER using (var www = UnityWebRequestTexture.GetTexture(url)) { yield return(www.SendWebRequest()); if (www.isHttpError || www.isNetworkError) { Log.E("Failed to download image: {0}", www.error); } else { texture = ((DownloadHandlerTexture)www.downloadHandler).texture; TextureCache.Instance.Put(url, texture); } callback(texture); } #else using (var www = new WWW(url)) { yield return(www); if (string.IsNullOrEmpty(www.error)) { texture = www.texture; TextureCache.Instance.Put(url, texture); } else { Log.E("Failed to download image: {0}", www.error); } callback(texture); } #endif }
internal static IEnumerator LoadTexture(string url, Action <Texture2D> callback) { Texture2D texture = TextureCache.Instance.Get(url); if (null != texture) { callback(texture); yield break; } using (var www = new WWW(url)) { yield return(www); if (string.IsNullOrEmpty(www.error)) { texture = www.texture; TextureCache.Instance.Put(url, texture); } else { Log.E("Failed to download image: {0}", www.error); } callback(texture); } }
protected virtual void CallBack(VideoAdCallbackArgments args) { switch (args.videoAdCallbackType) { case VideoAdCallbackType.LoadSuccess: if (null != AdLoaded) { AdLoaded(this); } break; case VideoAdCallbackType.FailedToLoad: if (null != AdFailedToLoad) { ErrorVideoAdCallbackArgments errorArg = (ErrorVideoAdCallbackArgments)args; Log.E("FailedToLoad errorCode = " + errorArg.errorCode); AdFailedToLoad(this, errorArg.errorCode); } break; case VideoAdCallbackType.FailedToPlay: if (null != AdFailedToPlay) { AdFailedToPlay(this); } break; case VideoAdCallbackType.AdShown: if (null != AdShown) { AdShown(this); } break; case VideoAdCallbackType.AdClosed: if (null != AdClosed) { AdClosed(this); } break; case VideoAdCallbackType.AdStarted: if (null != AdStarted) { AdStarted(this); } break; case VideoAdCallbackType.AdStopped: if (null != AdStopped) { AdStopped(this); } break; case VideoAdCallbackType.AdCompleted: if (null != AdCompleted) { AdCompleted(this); } break; case VideoAdCallbackType.AdClicked: if (null != AdClicked) { AdClicked(this); } break; case VideoAdCallbackType.InformationClicked: if (null != InformationClicked) { InformationClicked(this); } break; } }