Esempio n. 1
0
        /// <summary>
        /// Gets the bytes. Support Web Platform
        /// </summary>
        /// <param name="cdnRelativeUrl">Cdn relative URL.</param>
        /// <param name="callback">Callback.</param>
        public void GetBytes(string url, Action <byte[]> callback)
        {
            Entry e = GetCacheEntry(url);

            if (e != null)
            {
                FileInfo f = e.GetFile();
                if (f != null)
                {
                    FileAssetLoader.GetBytesFromFile(f, callback);
                }
                else
                {
#if WWW_MODULE
                    GetWWW(url, true, www =>
                    {
                        if (www != null && www.error.IsEmpty())
                        {
                            callback.Call(www.GetAsset <byte[]>());
                        }
                        else
                        {
                            fallback.GetBytes(url, callback);
                        }
                    });
#else
                    throw new Exception("Not implemented");
#endif
                }
            }
        }
Esempio n. 2
0
        public void GetTexture(string url, Action <Texture2D> callback)
        {
            Entry    e = GetCacheEntry(url);
            FileInfo f = e.GetFile();

            if (f != null)
            {
                FileAssetLoader.GetTextureFromFile(url, f, callback);
            }
            else
            {
#if WWW_MODULE
                GetWWW(url, true, www =>
                {
                    if (www != null)
                    {
                        // load image directly to set texture without delay
                        log.Debug("Loading texture {0}", url);
                        Texture2D texture = www.textureNonReadable;
                        if (texture == null)
                        {
                            AssetCache.log.Warn("Can't load textures {0}", url);
                        }
                        callback.Call(texture);
                    }
                    else
                    {
                        fallback.GetTexture(url, callback);
                    }
                });
#else
                throw new Exception("Not implemented");
#endif
            }
        }
Esempio n. 3
0
 /// <summary>
 /// Gets the bytes. Support Web Platform
 /// </summary>
 /// <param name="callback">Callback.</param>
 public void GetBytes(string url, Action <byte[]> callback)
 {
     GetRemote(url, f => {
         if (f != null)
         {
             FileAssetLoader.GetBytesFromFile(f, callback);
         }
         else
         {
             fallback.GetBytes(url, callback);
         }
     });
 }
Esempio n. 4
0
 public void GetAssetBundle(string url, bool unload, Action <AssetBundle> callback)
 {
     GetRemote(url, f =>
     {
         if (f != null)
         {
             FileAssetLoader.GetAssetBundleFromFile(f.FullName, callback);
         }
         else
         {
             fallback.GetAssetBundle(url, unload, callback);
         }
     });
 }
Esempio n. 5
0
 public void GetAssets <T>(string url, Action <IEnumerable <T> > callback, bool asyncHint) where T : Object
 {
     GetRemote(url, f => {
         FileAssetLoader.GetAssetsFromFile <T>(f, assets => {
             if (assets != null)
             {
                 callback(assets);
             }
             else
             {
                 fallback.GetAssets <T>(url, callback, asyncHint);
             }
         });
     });
 }
Esempio n. 6
0
        public void GetAssets <T>(string url, Action <IEnumerable <T> > callback, bool asyncHint) where T : Object
        {
            Entry    e = GetCacheEntry(url);
            FileInfo f = asyncHint? null : e.GetFile();

            if (f != null)
            {
                FileAssetLoader.GetAssetBundleFromFile(f.FullName, bundle => {
                    if (bundle != null)
                    {
                        T[] assets = bundle.LoadAllAssets <T>();
                        bundle.Unload(false);
                        callback.Call(assets);
                    }
                    else
                    {
                        fallback.GetAssets <T>(url, callback, asyncHint);
                    }
                });
            }
            else
            {
#if WWW_MODULE
                GetWWW(url, true, www =>
                {
                    if (www != null)
                    {
                        T[] assets = www.GetAssets <T>();
                        callback.Call(assets);
                    }
                    else
                    {
                        fallback.GetAssets <T>(url, callback, asyncHint);
                    }
                });
#else
                throw new Exception("Not implemented");
#endif
            }
        }
Esempio n. 7
0
 public void GetTexture(string url, Action <Texture2D> callback)
 {
     GetRemote(url, f => {
         if (f != null)
         {
             FileAssetLoader.GetTextureFromFile(url, f, tex => {
                 if (tex != null)
                 {
                     callback(tex);
                 }
                 else
                 {
                     fallback.GetTexture(url, callback);
                 }
             });
         }
         else
         {
             fallback.GetTexture(url, callback);
         }
     });
 }