コード例 #1
0
        public async Task Execute(BundleInfo info)
        {
            var path = Path.Combine(settings.BasePath, info.Path);

            if (bundles.Has(info.Id))
            {
                return;
            }

            var request = UnityWebRequestAssetBundle.GetAssetBundle(path);

            //log.Trace("REQUEST " + path);

            await request.SendWebRequest();

            var hasError = request.isHttpError || request.isNetworkError;

            if (hasError)
            {
                log.Warn("no bundle at " + path);
                return;
            }

            var bundle = DownloadHandlerAssetBundle.GetContent(request);

            bundles.Store(info.Id, bundle);

            info.Scenes?.Each(name => scenes.Load(name));
        }
コード例 #2
0
        private async Task InitContexts(IEnumerable <ContextInfo> contextInfos, IContext parentContext)
        {
            foreach (var contextInfo in contextInfos)
            {
                var scene = await scenes.Load(contextInfo.Id);

                var roots = scene.GetRootGameObjects();

                foreach (var root in roots)
                {
                    var rootComp = root.GetComponent <IContextInitializer>();

                    if (rootComp != null)
                    {
                        var childContext = rootComp.InitContext(contextInfo.Id, parentContext);

                        if (contextInfo.Contexts != null)
                        {
                            await InitContexts(contextInfo.Contexts, childContext);
                        }
                    }
                }
            }
        }