static public int AddParentBundle(IntPtr l)
 {
     try {
         LBoot.AssetBundleRef self = (LBoot.AssetBundleRef)checkSelf(l);
         System.String        a1;
         checkType(l, 2, out a1);
         self.AddParentBundle(a1);
         return(0);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Пример #2
0
        internal static IEnumerator LoadAsync(string parentBundlePath, string uri, int ttl)
        {
            string keyName = GetBundleKey(uri);

            GetTTLSettings(uri, ref ttl);

            AssetBundleRef abRef;

            while (loadingBundles.Contains(keyName))
            {
                LogUtil.Trace("BundleManager: is already Loading " + keyName);
                yield return(null);
            }

            if (TryGetRefreshedBundleRef(keyName, ttl, out abRef))
            {
                loadingBundles.Remove(keyName);
                abRef.AddParentBundle(parentBundlePath);
                yield break;
            }
            else
            {
                loadingBundles.Add(keyName);

                LogUtil.Trace("BundleManager: LoadAsyncWithNoCallback " + uri);
                AssetBundle bundle = null;

                if (loadWithWWW)
                {
                    var www = BundleEncoder.CreateBundleFromWWWAsync(uri, wwwVersion, wwwCrc);
                    while (!www.isDone)
                    {
                        yield return(null);
                    }
                    if (www.error == null || www.error == "")
                    {
                        bundle = www.assetBundle;
                    }
                    else
                    {
                        LogUtil.Error("BundleManager: creating bundle from WWW failed: " + www.error);
                    }
                }
                else
                {
                    var req = BundleEncoder.CreateBundleFromFileAsync(uri);
                    while (!req.isDone && !TryGetRefreshedBundleRef(keyName, ttl, out abRef))
                    {
                        yield return(null);
                    }

                    if (req.isDone)
                    {
                        bundle = req.assetBundle;
                    }
                }

                if (bundle != null)
                {
                    abRef             = new AssetBundleRef(uri, ttl);
                    abRef.AssetBundle = bundle;
                    dictAssetBundleRefs.Add(keyName, abRef);
                    listAssetBundleUris.Add(uri);
                    AddLoadHistory(uri, true);
                    loadingBundles.Remove(keyName);
                    abRef.AddParentBundle(parentBundlePath);
                }
                else
                {
                    if (TryGetRefreshedBundleRef(keyName, ttl, out abRef))
                    {
                        loadingBundles.Remove(keyName);
                        abRef.AddParentBundle(parentBundlePath);
                    }
                    else
                    {
                        LogUtil.Error("BundleManager: creating bundle from uri failed! " + uri);
                    }
                }

                loadingBundles.Remove(keyName);
            }
        }