Ejemplo n.º 1
0
        /// <summary>
        /// Load a asset bundle.
        /// </summary>
        public static void Load(string url, int version, Action <AssetBundle> onLoadComplete, ECacheMode cacheMode = ECacheMode.Cache)
        {
#if DEBUG_MY_ASSET_BUNDLE
            Debug.Log(string.Format("<color={0}>[{1}] Load()</color>: url=\"{2}\" - version=\"{3}\" - cacheMode=\"{4}\"", COLOR, typeof(MyAssetBundleManager).Name, url, version, cacheMode));
#endif

            if (mDictBundle.ContainsKey(url))
            {
                MyAssetBundle bundle = mDictBundle[url];
                if (bundle.Version >= version && bundle.Bundle != null)
                {
#if DEBUG_MY_ASSET_BUNDLE
                    Debug.Log(string.Format("<color={0}>[{1}] Load()</color>: loaded from cache", COLOR, typeof(MyAssetBundleManager).Name));
#endif

                    bundle.CacheMode = cacheMode;
                    if (onLoadComplete != null)
                    {
                        onLoadComplete(bundle.Bundle);
                    }
                    return;
                }
            }

            MyCoroutiner.Start(_DoLoadAssetBundle(url, version, onLoadComplete, cacheMode));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Load a sprite asynchronously.
        /// </summary>
        public static void LoadAsyncSprite(string path, Action <Sprite> onLoadComplete, bool isCache = true)
        {
            if (mDictSprite.ContainsKey(path))
            {
                if (onLoadComplete != null)
                {
                    onLoadComplete(mDictSprite[path]);
                }
                return;
            }

            MyCoroutiner.Start(_DoLoadAsyncSprite(path, onLoadComplete, isCache));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Load a material asynchronously.
        /// </summary>
        public static void LoadAsyncMaterial(string path, Action <Material> onLoadComplete, bool isCache = true)
        {
            if (mDictMaterial.ContainsKey(path))
            {
                if (onLoadComplete != null)
                {
                    onLoadComplete(mDictMaterial[path]);
                }
                return;
            }

            MyCoroutiner.Start(_DoLoadAsyncMaterial(path, onLoadComplete, isCache));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Load a prefab asynchronously.
        /// </summary>
        public static void LoadAsyncPrefab(string path, Action <float> onLoading, Action <GameObject> onLoadComplete, bool isCache = true)
        {
            if (mDictPrefab.ContainsKey(path))
            {
                if (onLoadComplete != null)
                {
                    onLoadComplete(mDictPrefab[path]);
                }
                return;
            }

            MyCoroutiner.Start(_DoLoadAsyncPrefab(path, onLoading, onLoadComplete, isCache));
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Load some sprites asynchronously.
 /// </summary>
 public static void LoadAsyncSprites(List <string> paths, Action <List <Sprite> > onLoadComplete, bool isCache = true)
 {
     MyCoroutiner.Start(_DoLoadAsyncSprites(paths, onLoadComplete, isCache));
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Load some prefabs asynchronously.
 /// </summary>
 public static void LoadAsyncPrefabs(List <string> paths, Action <List <GameObject> > onLoadComplete, bool isCache = true)
 {
     MyCoroutiner.Start(_DoLoadAsyncPrefabs(paths, onLoadComplete, isCache));
 }