Exemplo n.º 1
0
    //	returns cached url if the file is there
    public static string GetCachedUrl(string url)
    {
        //	if url is local, no cache
        if (PopUrl.IsLocalUrl(url))
        {
            return(url);
        }

        string path = urlToCachePath(url);

        if (!File.Exists(path))
        {
            //Debug.LogWarning("dont have cache url:"+url);
            return(url);
        }

        return(PopUrl.MakeFileUrl(path));
    }
Exemplo n.º 2
0
    public static void WriteCache(WWW www)
    {
        //	skip if url in cached path
        var CachePrefix = PopUrl.MakeFileUrl(GetCachePath());

        if (www.url.StartsWith(CachePrefix))
        {
            return;
        }

        try
        {
            var CachePath = urlToCachePath(www.url);
            File.WriteAllBytes(CachePath, www.bytes);
            Debug.Log("Wrote " + www.url + " cache to " + CachePath);
        }
        catch (System.Exception e)
        {
            Debug.LogError("Failed to write cache (" + www.url + "); " + e.Message);
        }
    }