Esempio n. 1
0
        public IEnumerator LoadAllDependenciesAsync(string fname, int ttl)
        {
            if (manifest == null)
            {
                LogUtil.Error("manifest == null");
                yield break;
            }

            string dpname = fname.Replace("\\", "/");

            // Get dependecies from the AssetBundleManifest object..
            string[] dependencies = manifest.GetAllDependencies(dpname);

            var length = dependencies.Length;

            if (length == 0)
            {
                yield break;
            }

            // Record and load all dependencies.
            var count = (float)length;

            for (int i = 0; i < length; i++)
            {
                var depend = RemapVariantName(dependencies[i]);
                LogUtil.Trace(fname + ":dependancy:" + depend);
                var iter = BundleManager.LoadAsync(fname, depend, ttl);
                while (iter.MoveNext())
                {
                    yield return(null);
                }
            }
        }
Esempio n. 2
0
        public bool CanUnload()
        {
            if (assetRequests != null)
            {
                foreach (var pair in this.assetRequests)
                {
                    if (!pair.Value.isDone)
                    {
                        return(false);
                    }
                }
            }

            if (parentBundles != null)
            {
                foreach (var pair in this.parentBundles)
                {
                    var parentBundlePath = pair.Key;
                    var parentBundle     = BundleManager.GetBundleRef(parentBundlePath);
                    if (parentBundle != null && !parentBundle.CanUnload())
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
Esempio n. 3
0
        public static void UnloadDeadBundles()
        {
#if PROFILE_FILE
            Profiler.BeginSample("BundleHelper.UnloadDeadBundles");
#endif
            BundleManager.UnloadDeadBundles();
#if PROFILE_FILE
            Profiler.EndSample();
#endif
        }
Esempio n. 4
0
        public static void UnloadDeadBundles(bool unloadAllLoadedObjects, int iterCount)
        {
#if PROFILE_FILE
            Profiler.BeginSample("BundleHelper.UnloadDeadBundles");
#endif
            BundleManager.UnloadDeadBundles(unloadAllLoadedObjects, iterCount);
#if PROFILE_FILE
            Profiler.EndSample();
#endif
        }
Esempio n. 5
0
        /// <summary>
        /// Reset the bundle manager
        /// </summary>
        public static void Reset()
        {
#if PROFILE_FILE
            Profiler.BeginSample("BundleHelper.Reset");
#endif
            BundleConfig.Reset();
            BundleManager.Reset();
#if PROFILE_FILE
            Profiler.EndSample();
#endif
        }
 static public int constructor(IntPtr l)
 {
     try {
         LBoot.BundleManager o;
         o = new LBoot.BundleManager();
         pushValue(l, o);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Esempio n. 7
0
        public static string[] GetAllDependencies(string uri)
        {
#if PROFILE_FILE
            Profiler.BeginSample("BundleHelper.GetAllDependencies");
#endif
            var fixedUri = fixBundleUri(uri);
            var depends  = BundleManager.GetAllDependencies(fixedUri);
#if PROFILE_FILE
            Profiler.EndSample();
#endif
            return(depends);
        }
Esempio n. 8
0
        /// <summary>
        /// Unloads the asset bundle
        /// </summary>
        /// <param name="uri">URI.</param>
        public static void Unload(string uri, bool unloadAllLoadedObjects)
        {
#if PROFILE_FILE
            Profiler.BeginSample("BundleHelper.Unload");
#endif
            var fixedUri = fixBundleUri(uri);
            BundleManager.Unload(fixedUri, unloadAllLoadedObjects);

#if PROFILE_FILE
            Profiler.EndSample();
#endif
        }
Esempio n. 9
0
        /// <summary>
        /// Loads the asset bundle with all its dependencies.
        /// </summary>
        /// <returns>The with dependencies.</returns>
        /// <param name="uri">URI.</param>
        public static AssetBundleRef LoadWithDependencies(string uri, int ttl)
        {
#if PROFILE_FILE
            Profiler.BeginSample("BundleHelper.LoadWithDependencies");
#endif
            uri = fixBundleUri(uri);
            AssetBundleRef bundle = BundleManager.LoadWithDependencies(uri, ttl);
#if PROFILE_FILE
            Profiler.EndSample();
#endif
            return(bundle);
        }
 static public int GetBundleDependencies(IntPtr l)
 {
     try {
         LBoot.BundleManager self = (LBoot.BundleManager)checkSelf(l);
         var ret = self.GetBundleDependencies();
         pushValue(l, ret);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Esempio n. 11
0
        /// <summary>
        /// Load the asset bundle with specified uri.
        /// </summary>
        /// <param name="uri">path to the assset bundle </param>
        public static AssetBundleRef Load(string uri, int ttl)
        {
#if PROFILE_FILE
            Profiler.BeginSample("BundleHelper.Load");
#endif
            uri = fixBundleUri(uri);
            var result = BundleManager.Load(uri, ttl);

#if PROFILE_FILE
            Profiler.EndSample();
#endif
            return(result);
        }
Esempio n. 12
0
        private static IEnumerator _LoadWithDependenciesAsync(string uri, int ttl, Action <AssetBundleRef> onComplete)
        {
#if PROFILE_FILE
            // Profiler.BeginSample("BundleHelper._LoadWithDependenciesAsync");
#endif
            var            fixedUri    = fixBundleUri(uri);
            AssetBundleRef assetBundle = null;
            var            iter        = BundleManager.LoadWithDependenciesAsync(fixedUri, ttl);
            while (iter.MoveNext())
            {
                yield return(null);
            }
            assetBundle = BundleManager.GetBundleRef(fixedUri);
            onComplete(assetBundle);
#if PROFILE_FILE
            // Profiler.EndSample();
#endif
        }
Esempio n. 13
0
        public static GameObject LoadAndCreate(string name, int ttl)
        {
#if UNITY_EDITOR && LOAD_FROM_EDITOR
            return(LoadAndCreateInEditor(name, ttl));
#else
#if PROFILE_FILE
            Profiler.BeginSample("BundleHelper.LoadAndCreate");
#endif
            var uri       = fixBundleUri(name);
            var bundle    = BundleManager.LoadWithDependencies(uri, ttl);
            var assetName = getAssetName(name);
            var go        = bundle.LoadAsset(assetName) as GameObject;
            var result    = GameObject.Instantiate(go);

#if PROFILE_FILE
            Profiler.EndSample();
#endif
            return(result);
#endif
        }
Esempio n. 14
0
        public void LoadAllDependencies(string fname, int ttl)
        {
            if (manifest == null)
            {
                LogUtil.Error("manifest==null");
                return;
            }

#if PROFILE_FILE
            Profiler.BeginSample("BundleDependencies.LoadAllDependencies");
#endif
            string dpname = fname.Replace("\\", "/");
//            int idx = dpname.LastIndexOf("/") + 1;
//            dpname = dpname.Substring(idx, dpname.Length - idx);

            // Get dependecies from the AssetBundleManifest object..
            string[] dependencies = manifest.GetAllDependencies(dpname);

            var length = dependencies.Length;
            if (length == 0)
            {
                return;
            }

            // Record and load all dependencies.
            for (int i = 0; i < length; i++)
            {
                var depend = RemapVariantName(dependencies[i]);
                LogUtil.Trace(fname + ":dependancy:" + depend);
                var bundle = BundleManager.Load(depend, ttl);
                if (bundle != null)
                {
                    bundle.AddParentBundle(fname);
                }
            }

#if PROFILE_FILE
            Profiler.EndSample();
#endif
        }
Esempio n. 15
0
        private static IEnumerator _LoadLevelAdditiveAsync(string uri, int ttl, Action onComplete, Action <AsyncLoadingType, float> onProgress = null)
        {
#if PROFILE_FILE
            // Profiler.BeginSample("BundleHelper.LoadLevelAdditiveAsync");
#endif
            var fixedUri = fixBundleUri(uri);
#if !UNITY_EDITOR || !LOAD_FROM_EDITOR
            AssetBundleRef assetBundle = null;
            var            iter        = BundleManager.LoadWithDependenciesAsync(fixedUri, ttl, bundle => assetBundle = bundle);
            while (iter.MoveNext())
            {
                if (onProgress != null)
                {
                    onProgress(AsyncLoadingType.AssetBundle, (float)iter.Current);
                }
                yield return(null);
            }
#endif
            var asyncOp2 = Application.LoadLevelAdditiveAsync(getAssetName(uri));
            while (!asyncOp2.isDone)
            {
                if (onProgress != null)
                {
                    onProgress(AsyncLoadingType.Scene, asyncOp2.progress);
                }
                yield return(null);
            }

            yield return(new WaitForEndOfFrame());

            onComplete();

#if PROFILE_FILE
            // Profiler.EndSample();
#endif
        }
Esempio n. 16
0
        private static IEnumerator _LoadWithDependenciesAsync(string uri, int ttl, LuaTable lua)
        {
#if PROFILE_FILE
            // Profiler.BeginSample("BundleHelper._LoadWithDependenciesAsync");
#endif
            var            fixedUri    = fixBundleUri(uri);
            AssetBundleRef assetBundle = null;
            var            iter        = BundleManager.LoadWithDependenciesAsync(fixedUri, ttl);
            int            count       = 0;
            while (iter.MoveNext())
            {
                count++;
                yield return(null);
            }

            assetBundle = BundleManager.GetBundleRef(fixedUri);
            if (lua != null)
            {
                lua.setOneLevelField("bundle", assetBundle);
            }
#if PROFILE_FILE
            // Profiler.EndSample();
#endif
        }
Esempio n. 17
0
 public static void SetBundleVariants(string[] variants)
 {
     BundleManager.SetBundleVariantes(variants);
 }
Esempio n. 18
0
        public static string GetRealBundlePath(string uri)
        {
            var fixedUri = fixBundleUri(uri);

            return(BundleManager.RemapVariantBundleName(fixedUri));
        }