コード例 #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);
                }
            }
        }
コード例 #2
0
ファイル: BundleManager.cs プロジェクト: swordlegend/army_ru
        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);
        }
コード例 #3
0
ファイル: BundleHelper.cs プロジェクト: swordlegend/army_ru
        public static void UnloadDeadBundles()
        {
#if PROFILE_FILE
            Profiler.BeginSample("BundleHelper.UnloadDeadBundles");
#endif
            BundleManager.UnloadDeadBundles();
#if PROFILE_FILE
            Profiler.EndSample();
#endif
        }
コード例 #4
0
ファイル: BundleHelper.cs プロジェクト: swordlegend/army_ru
        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
        }
コード例 #5
0
ファイル: BundleHelper.cs プロジェクト: swordlegend/army_ru
        /// <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
        }
コード例 #6
0
 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));
     }
 }
コード例 #7
0
ファイル: BundleHelper.cs プロジェクト: swordlegend/army_ru
        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);
        }
コード例 #8
0
ファイル: BundleHelper.cs プロジェクト: swordlegend/army_ru
        /// <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
        }
コード例 #9
0
ファイル: BundleHelper.cs プロジェクト: swordlegend/army_ru
        /// <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);
        }
コード例 #10
0
 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));
     }
 }
コード例 #11
0
ファイル: BundleHelper.cs プロジェクト: swordlegend/army_ru
        /// <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);
        }
コード例 #12
0
ファイル: BundleHelper.cs プロジェクト: swordlegend/army_ru
        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
        }
コード例 #13
0
ファイル: BundleHelper.cs プロジェクト: swordlegend/army_ru
        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
        }
コード例 #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
        }
コード例 #15
0
ファイル: BundleHelper.cs プロジェクト: swordlegend/army_ru
        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
        }
コード例 #16
0
ファイル: BundleHelper.cs プロジェクト: swordlegend/army_ru
        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
        }
コード例 #17
0
ファイル: BundleHelper.cs プロジェクト: swordlegend/army_ru
 public static void SetBundleVariants(string[] variants)
 {
     BundleManager.SetBundleVariantes(variants);
 }
コード例 #18
0
ファイル: BundleHelper.cs プロジェクト: swordlegend/army_ru
        public static string GetRealBundlePath(string uri)
        {
            var fixedUri = fixBundleUri(uri);

            return(BundleManager.RemapVariantBundleName(fixedUri));
        }