Exemplo n.º 1
0
    private TextureManager.TextureInfo LoadFile(string path, Action <Texture2D> callback, float timeoutSeconds = 30f, bool isCache = true)
    {
        TextureManager.TextureInfo info = new TextureManager.TextureInfo();
        info.path = path;
        TextureManager.SaveData.CacheInfo cacheInfo = this.CreateCacheInfo(path);
        Action <Texture2D> callback2 = delegate(Texture2D loadTex)
        {
            info.texture2D = loadTex;
            info.coroutine = null;
            if (callback != null)
            {
                callback(info.texture2D);
            }
        };

        if (this.Containts(cacheInfo))
        {
            info.coroutine = this.LoadPersistentFile(path, cacheInfo, callback2);
        }
        else
        {
            info.coroutine = this.LoadWWWHelper(path, cacheInfo, callback2, timeoutSeconds, isCache);
        }
        return(info);
    }
Exemplo n.º 2
0
    public Coroutine Load(string path, Action <Texture2D> callback, float timeoutSeconds = 30f, bool isCache = true)
    {
        TextureManager.TextureInfo textureInfo = null;
        for (int i = 0; i < this.infoList.Count; i++)
        {
            if (this.infoList[i].path == path)
            {
                textureInfo = this.infoList[i];
                break;
            }
        }
        bool flag = textureInfo == null;

        if (textureInfo != null)
        {
            if (textureInfo.coroutine != null)
            {
                base.StopCoroutine(textureInfo.coroutine);
                this.infoList.Remove(textureInfo);
                flag = true;
            }
            else if (callback != null)
            {
                callback(textureInfo.texture2D);
            }
        }
        if (flag)
        {
            TextureManager.TextureInfo textureInfo2 = this.LoadFile(path, callback, timeoutSeconds, isCache);
            if (isCache)
            {
                this.infoList.Add(textureInfo2);
            }
            return(textureInfo2.coroutine);
        }
        return(null);
    }