Beispiel #1
0
    public void ShowRequiredUpdate(string storeUrl)
    {
        UICustomeDialogueOption option = new UICustomeDialogueOption();

        option.title     = EB.Localizer.GetString("ID_SPARX_APP_UPDATE_TITLE");
        option.body      = EB.Localizer.GetString("ID_SPARX_APP_UPDATE_MESSAGE");
        option.accept    = UICustomeDialogueOption.ButtonGo;
        option.minHeight = UICustomeDialogueOption.ThreeLineHeight;
        if (!string.IsNullOrEmpty(storeUrl))
        {
            EB.Uri    uri = new EB.Uri(storeUrl);
            Hashtable qs  = EB.QueryString.Parse(uri.GetComponent(EB.Uri.Component.Query, string.Empty));
            qs.Add("platform", EB.Sparx.Device.Platform);
            qs.Add("source", EB.Sparx.Device.Source);
            qs.Add("child", EB.Sparx.Device.ChildSource);
            uri.SetComponent(EB.Uri.Component.Query, EB.QueryString.Stringify(qs));

            option.onClick = delegate(eUIDialogueButtons button, UIDialogeOption opt)
            {
                Application.OpenURL(opt.param as string);
            };

            option.param   = uri.ToString();
            option.buttons = eUIDialogueButtons.Accept;
        }
        else
        {
            option.buttons = eUIDialogueButtons.None;
        }

        UIStack.Instance.ShowDialog(option);
    }
Beispiel #2
0
    /// <summary>
    /// 异步加载Texture
    /// </summary>
    /// <param name="info"></param>
    /// <returns></returns>
    IEnumerator ProcessNextTexture(TextureInfo info)
    {
        string url = GetUrl(info.textureName);

        // If we didn't find an url and our textures are prepended with our
        // Bundles/UI/ path, strip it and look for the path again
        if (string.IsNullOrEmpty(url))
        {
            url = GetUrl(info.textureName.Replace("Bundles/UI/", string.Empty));
        }

#if TEXTUREPOOL_SPEW
        EB.Debug.Log("TexturePoolManager - LOADING " + url);
#endif

        // evict any old textures before moving on
        Evict();

        UnityWebRequest textureLoader = null;
        bool            disposable    = true;
        EB.Uri          uri           = new EB.Uri();
        if (uri.Parse(url))
        {
            for (int i = 0; i < kRetryIntervals; ++i)
            {
                textureLoader = EB.Cache.LoadFromCacheOrDownload(url, out disposable);
                if (textureLoader == null)
                {
                    break;
                }

                yield return(textureLoader.SendWebRequest());

                if (string.IsNullOrEmpty(textureLoader.error))
                {
                    break;
                }
                else if (url.StartsWith("file://"))
                {
                    // file error are going to make a difference with a retry
                    break;
                }

#if UNITY_EDITOR
                // Since all the texture are in Resources folder when running in editor, we don't want to delay this
                if (Application.isEditor)
                {
                    break;
                }
#else
                EB.Debug.LogWarning("COULD NOT FIND TEXTURE: " + url);
                yield return(_waits[i]);
#endif
            }
        }

        if (Application.isEditor)
        {
            yield return(new WaitForSeconds(0.15f));
        }

        if (textureLoader != null && (textureLoader.isHttpError || textureLoader.isNetworkError))
        {
            // If we loaded from cache or file, we want to mark the textures properly
            // so they are destroyed or released properly later on
            if (textureLoader.url.StartsWith("file://"))
            {
                info.source = TextureInfo.eTextureSource.Resources;
            }

            info.texture            = DownloadHandlerTexture.GetContent(textureLoader);
            info.texture.wrapMode   = TextureWrapMode.Clamp;
            info.texture.name       = info.textureName;
            info.successfullyLoaded = true;
            info.DoCallbacks();

#if TEXTUREPOOL_SPEW
            EB.Debug.LogWarning("ON-DEMAND LOAD FROM {0} THERE ARE NOW {1} IN THE POOL", url, _all.Count);
#endif
        }
        else
        {
            // Texture wasn't found in the bundle - Look for it in the resources folder only if in editor
            // Resources load requires no extension present in the path name
            string strippedPath = info.textureName.Replace(System.IO.Path.GetExtension(info.textureName), string.Empty);
            info.texture = Resources.Load(strippedPath) as Texture2D;
            if (info.texture == null)
            {
                EB.Debug.LogWarning("Texture not found at '{0}' or '{1}'", info.textureName, strippedPath);
            }
            else
            {
                info.texture.wrapMode   = TextureWrapMode.Clamp;
                info.texture.name       = info.textureName;
                info.source             = TextureInfo.eTextureSource.Resources;
                info.successfullyLoaded = true;
            }

            info.DoCallbacks();
        }

        if (textureLoader != null)
        {
            if (disposable == true)
            {
                textureLoader.Dispose();
            }
            else
            {
                EB.Cache.DisposeOnComplete(textureLoader);
            }
        }

        --_concurrentRequests;
    }