Ejemplo n.º 1
0
        private IEnumerator LoadImageAsync(string url, ImageLoaderSubscriber sub, string nameToUseInCache)
        {
            // Make a request then to download the source
            WWW www = new WWW(url);

            yield return(www);

            // Cache the image on the machine.
            File.WriteAllBytes(nameToUseInCache, www.bytes);
            sub.OnImageLoad(url, www.texture);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Attempts to load an image from either the filesystem or cache, or
        /// will make an http request to fetch the image for asyncronously over
        /// http
        /// </summary>
        /// <param name="url">URL.</param>
        /// <param name="sub">Sub.</param>
        public static void LoadImage(string url, ImageLoaderSubscriber sub)
        {
            if (!Directory.Exists("cache"))
            {
                Directory.CreateDirectory("cache");
            }

            // Get Md5 hash...
            string hashName = "something hashed";

            // Try Loading from memory...
            string[] chunks    = url.Split('.');
            string   extension = chunks[chunks.Length - 1];

            string filePath = Path.Combine(Path.Combine(Directory.GetCurrentDirectory(), "cache"), hashName + "." + extension);

            GetRequestObject().LoadImage(url, sub, filePath);
        }
Ejemplo n.º 3
0
 public void LoadImage(string url, ImageLoaderSubscriber sub, string nameToUseInCache)
 {
     StartCoroutine(LoadImageAsync(url, sub, nameToUseInCache));
 }