Example #1
0
        void InitUnity()
        {
            Application.targetFrameRate = LBootApp.TARGET_FRAME_RATE; // not useful if vsync is set
            BundleEncoder.Init(LBootApp.BUNDLE_KEY, LBootApp.BUNDLE_IV);

            if (initGameObject != null)
            {
                /*
                 *              var scheduler = initGameObject.GetComponent<SchedulerBehaviour>();
                 *              if (scheduler != null) {
                 *                      GlobalScheduler.Init(scheduler);
                 *              } else {
                 *                      LogUtil.Error("BootstrapApp: initUnity failed! no Scheduler component found");
                 *              }
                 */
                var updater = initGameObject.GetComponent <GlobalUpdateBehaviour>();
                if (updater == null)
                {
                    LogUtil.Error("BootstrapApp: initUnity failed! no GlobalUpdateBehaviour component found");
                }
            }
            else
            {
                LogUtil.Error("BootstrapApp: initUnity failed! initGameObject is null");
            }
        }
 static public int constructor(IntPtr l)
 {
     try {
         LBoot.BundleEncoder o;
         o = new LBoot.BundleEncoder();
         pushValue(l, o);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Example #3
0
        // Load an AssetBundle, without loading its dependencies
        public static AssetBundleRef Load(string uri, int ttl)
        {
            string         keyName = GetBundleKey(uri);
            AssetBundleRef abRef;

            GetTTLSettings(uri, ref ttl);

            if (TryGetRefreshedBundleRef(keyName, ttl, out abRef))
            {
                loadingBundles.Remove(keyName);
                return(abRef);
            }
            else
            {
                LogUtil.Trace("BundleManager: Load " + uri);
                AssetBundle bundle = null;

                if (loadWithWWW)
                {
                    bundle = BundleEncoder.CreateBundleFromWWW(uri, wwwVersion, wwwCrc);
                }
                else
                {
                    bundle = BundleEncoder.CreateBundleFromFile(uri);
                }

                if (bundle != null)
                {
                    abRef             = new AssetBundleRef(uri, ttl);
                    abRef.AssetBundle = bundle;
                    dictAssetBundleRefs.Add(keyName, abRef);
                    listAssetBundleUris.Add(uri);
                    loadingBundles.Remove(keyName);
                    AddLoadHistory(uri, true);
                    return(abRef);
                }
                else
                {
                    if (TryGetRefreshedBundleRef(keyName, ttl, out abRef))
                    {
                        loadingBundles.Remove(keyName);
                        return(abRef);
                    }

                    LogUtil.Error("BundleManager: creating bundle from uri failed! " + uri);
                }
            }

            return(null);
        }
Example #4
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);
            }
        }