Beispiel #1
0
        private static ACacheItem _Android_BundleCreate(WebArgument argument)
        {
            var localPath     = argument.localPath;
            var info          = WebManager.Instance.GetMappingInfo(localPath);
            var isSmallEnough = _IsSmallEnough(info);

            ACacheItem cacheItem;

            if (info.loadType == LoadType.Builtin)
            {
                var webType = isSmallEnough ? WebType.LoadFromCacheOrDownload : WebType.NewWWW;
                cacheItem = new RemoteBundleCacheItem(argument.localPath, webType);
                return(cacheItem);
            }

            // 大文件加載,以主城為例:
            // 1. 使用NewWWW方式,加載平緩,但會產生一個4MB的WebStream
            // 2. 使用CreateFromFile,不會產生WebStream,但加載會卡頓15s

            var isNewWWW = (argument.flags & WebFlags.NewWWW) != 0;
            var isLoadFromCacheOrDownload = isSmallEnough || !isNewWWW;

            if (isLoadFromCacheOrDownload)
            {
                cacheItem = new RemoteBundleCacheItem(argument.localPath, WebType.LoadFromCacheOrDownload);
            }
            else
            {
                cacheItem = new RemoteBundleCacheItem(argument.localPath, WebType.NewWWW);
            }

            return(cacheItem);
        }
Beispiel #2
0
        public WebPrefab LoadWebPrefab(string localPath, Action <WebPrefab> handler)
        {
            var argument = new WebArgument {
                localPath = localPath
            };
            var webPrefab = LoadWebPrefab(argument, handler);

            return(webPrefab);
        }
Beispiel #3
0
        public static ACacheItem Create(WebArgument argument)
        {
            var localPath = argument.localPath;
            var isBundle  = localPath.EndsWith(Constants.BundleExtension);

            var cacheItem = isBundle ? _lpfnBundleCreate(argument) : new WWWCacheItem(argument.localPath, WebType.NewWWW);

            cacheItem.unloadAllLoadedObjects = (argument.flags & WebFlags.UnloadAllLoadedObjects) != 0;
            return(cacheItem);
        }
Beispiel #4
0
        internal InnerWebPrefab(WebArgument argument)
        {
            argument.flags |= WebFlags.UnloadAllLoadedObjects;
            this.localPath  = argument.localPath;
            this.argument   = argument;
            var mainArgument = new WebArgument {
                localPath = localPath, flags = argument.flags
            };
            var mainWeb = WebManager.Instance.LoadWebItem(mainArgument, _OnLoadMainWeb);

            _InitCallback_MainWeb(mainWeb);
        }
Beispiel #5
0
        private void _OnLoadMainWeb(WebItem web)
        {
            _InitCallback_MainWeb(web);

            if (null != web.error)
            {
                error = string.Format("[InnerWebPrefab._OnLoadMainAsset()] {0}, web.error={1}, web={2}"
                                      , Path.GetFileName(web.argument.localPath), web.error, web);
                _OnLoadAll(web);
                return;
            }

            var bundle = web.assetBundle;

            if (null == bundle)
            {
                error = string.Format("[InnerWebPrefab._OnLoadMainAsset()] bundle is null, web={0}", web);
                _OnLoadAll(web);
                return;
            }

            var manif = WebManager.Instance.Manifest;

            string[] dependences = manif.GetAllDependencies(web.argument.localPath);
            if (null == dependences)
            {
                error = string.Format("[InnerWebPrefab._OnLoadMainAsset()] dependences is null, web={0}", web);
                _OnLoadAll(web);
                return;
            }

            var nodes = new IWebNode[dependences.Length];

            for (int i = 0; i < dependences.Length; ++i)
            {
                var arg = new WebArgument {
                    localPath = dependences [i], flags = WebFlags.UnloadAllLoadedObjects
                };
                var sharedPart = WebManager.Instance.LoadWebItem(arg, _OnLoadSimplePart);
                nodes[i] = sharedPart;
            }

            _partGroutp = new WebGroup(nodes, _OnLoadAll);
            web.HoldBabies(ref nodes);
        }
Beispiel #6
0
        private static ACacheItem _iPhone_BundleCreate(WebArgument argument)
        {
            var localPath = argument.localPath;
            var isLoadFromCacheOrDownload = (argument.flags & WebFlags.NewWWW) == 0;

            ACacheItem cacheItem;

            if (isLoadFromCacheOrDownload)
            {
                cacheItem = new RemoteBundleCacheItem(argument.localPath, WebType.LoadFromCacheOrDownload);
            }
            else
            {
                cacheItem = new RemoteBundleCacheItem(argument.localPath, WebType.NewWWW);
            }

            return(cacheItem);
        }
Beispiel #7
0
        internal WebPrefab(WebArgument argument, Action <WebPrefab> handler)
        {
            this.argument = argument;
            var localPath = argument.localPath;

            InnerWebPrefab inner;

            if (!_innerPrefabs.TryGetValue(localPath, out inner))
            {
                inner = new InnerWebPrefab(argument);
                _innerPrefabs.Add(localPath, inner);
            }

            _size  = inner.size;
            _inner = inner;
            _inner.AddReference();

            _loadingInnerRoutine = CoroutineManager.StartCoroutine(_CoLoadInnerWebPrefab(handler));
        }
Beispiel #8
0
        private static ACacheItem _Editor_Android_BundleCreate(WebArgument argument)
        {
            var localPath                 = argument.localPath;
            var info                      = WebManager.Instance.GetMappingInfo(localPath);
            var isSmallEnough             = _IsSmallEnough(info);
            var isNewWWW                  = (argument.flags & WebFlags.NewWWW) != 0;
            var isLoadFromCacheOrDownload = isSmallEnough || !isNewWWW;

            ACacheItem cacheItem;

            if (isLoadFromCacheOrDownload)
            {
                cacheItem = new LocalBundleCacheItem(argument.localPath);
            }
            else
            {
                cacheItem = new RemoteBundleCacheItem(argument.localPath, WebType.NewWWW);
            }

            return(cacheItem);
        }
Beispiel #9
0
        public WebPrefab LoadWebPrefab(WebArgument argument, Action <WebPrefab> handler)
        {
            var webPrefab = new WebPrefab(argument, handler);

            return(webPrefab);
        }
Beispiel #10
0
        public WebItem LoadWebItem(WebArgument argument, Action <WebItem> handler)
        {
            var web = new WebItem(argument, handler);

            return(web);
        }