コード例 #1
0
ファイル: ResolverTree.cs プロジェクト: zhaoyin/officeOBA
        /// <summary>
        /// 扫描解析插件的层次,最终获取一个有序的列表
        /// </summary>
        /// <param name="bundles"></param>
        /// <param name="resolvers"></param>
        public void ScanBundlesByOrder(IList <AbstractBundle> bundles, IList <ResolverNode> resolvers)
        {
            if (resolvers.Count == 0)
            {
                return;
            }
            // 定义层次列表
            ResolverNodeCollection providers = new ResolverNodeCollection();

            // 扫描上一级层次
            foreach (var resolver in resolvers)
            {
                if (resolver.DepencyProvidersBy.Count == 0)
                {
                    continue;
                }
                // 获取当前解析插件的所有依赖插件,并进行降序排列
                ResolverNode[] resolverBundles = resolver.DepencyProvidersBy.ToArray();
                foreach (var provider in resolverBundles)
                {
                    if (provider.DesLevel == resolver.DesLevel + 1)
                    {
                        providers.Add(provider);
                    }
                }
            }
            // 调整扫描的层次链表
            ResolverNode[] newResolvers = providers.ToArray();
            BundleUtil.Sort(newResolvers, 0, newResolvers.Length);
            // 合并当前层次
            Combine(bundles, newResolvers);
            // 扫描下一个子层次结构
            this.ScanBundlesByOrder(bundles, newResolvers);
        }
コード例 #2
0
    IEnumerator _CopyManifestFromStreamingAssets(Action callback)
    {
        DirectoryInfo dir        = new DirectoryInfo(BundleUtil.GetReadOnlyDirectory() + "/");
        Uri           baseUri    = new Uri(dir.FullName);
        IDownloader   downloader = new WWWDownloader(baseUri, false);

        // 下载 Manifest
        IProgressResult <Progress, BundleManifest> manifestResult = downloader.DownloadManifest(BundleSetting.ManifestFilename);

        yield return(manifestResult.WaitForDone());

        if (manifestResult.Exception != null)
        {
            LogManager.Log("Downloads BundleManifest failure.Error:{0}", manifestResult.Exception);
            yield break;
        }

        IResources _resources = CreateResources();

        context.GetContainer().Register <IResources>(_resources);
        if (callback != null)
        {
            callback.Invoke();
        }
    }
コード例 #3
0
        /// <summary>
        /// 插件数据完整性解析
        /// </summary>
        /// <param name="bundles"></param>
        /// <returns></returns>
        public bool ResolveForValidation(IList <AbstractBundle> bundles)
        {
            // 检查数据不完整的插件
            IList <AbstractBundle> removalPendings = new List <AbstractBundle>();

            foreach (AbstractBundle bundle in bundles)
            {
                // 基础性数据完整性解析
                if (!BasicResolveForValidation(bundle))
                {
                    bundle.ResolveState = ResolveState.Resolved | ResolveState.Fault;
                    removalPendings.Add(bundle);
                    continue;
                }
                // 宿主数据完整性解析
                if (bundle.BundleData.BundleType == BundleType.Host &&
                    !ResolveHostForValidation(bundle))
                {
                    bundle.ResolveState = ResolveState.Resolved | ResolveState.Fault;
                    removalPendings.Add(bundle);
                }
                else if (!ResolveFragmentForValidation(bundle))
                {
                    bundle.ResolveState = ResolveState.Resolved | ResolveState.Fault;
                    removalPendings.Add(bundle);
                }
            }
            // 将解析失败的插件从当前待解析插件列表中移除
            BundleUtil.Remove <AbstractBundle>(bundles, removalPendings);

            return(bundles.Count != 0);
        }
コード例 #4
0
        public IEnumerator Download(List <string> bundleNames)
        {
            this.downloading = true;

            try
            {
                IProgressResult <Progress, BundleManifest> manifestResult = this.downloader.DownloadManifest(BundleSetting.ManifestFilename);

                yield return(manifestResult.WaitForDone());

                if (manifestResult.Exception != null)
                {
                    Debug.LogFormat("Downloads BundleManifest failure.Error:{0}", manifestResult.Exception);
                    yield break;
                }

                BundleManifest manifest = manifestResult.Result;

                IProgressResult <float, List <BundleInfo> > bundlesResult = this.downloader.GetDownloadList(manifest);

                yield return(bundlesResult.WaitForDone());

                List <BundleInfo> bundles = bundlesResult.Result.FindAll(obj => bundleNames.Contains(obj.FullName));

                if (bundles == null || bundles.Count <= 0)
                {
                    Debug.LogFormat("Please clear cache and remove StreamingAssets,try again.");
                    yield break;
                }

                IProgressResult <Progress, bool> downloadResult = this.downloader.DownloadBundles(bundles);
                downloadResult.Callbackable().OnProgressCallback(p =>
                {
                    Debug.LogFormat("Downloading {0:F2}KB/{1:F2}KB {2:F3}KB/S", p.GetCompletedSize(UNIT.KB), p.GetTotalSize(UNIT.KB), p.GetSpeed(UNIT.KB));
                });

                yield return(downloadResult.WaitForDone());

                if (downloadResult.Exception != null)
                {
                    Debug.LogFormat("Downloads AssetBundle failure.Error:{0}", downloadResult.Exception);
                    yield break;
                }

                if (this.resources != null)
                {
                    //update BundleManager's manifest
                    BundleManager manager = (this.resources as BundleResources).BundleManager as BundleManager;
                    manager.BundleManifest = manifest;
                }

#if UNITY_EDITOR
                UnityEditor.EditorUtility.OpenWithDefaultApp(BundleUtil.GetReadOnlyDirectory());
#endif
            }
            finally
            {
                this.downloading = false;
            }
        }
コード例 #5
0
        public AssetBundleManager(string bundleDownladerUri, AssetPath assetPath = AssetPath.streamingAssetsPath)
        {
            switch (assetPath)
            {
            case AssetPath.streamingAssetsPath:
                uriString = BundleUtil.GetReadOnlyDirectory();
                break;

            case AssetPath.persistentDataPath:
                uriString = BundleUtil.GetStorableDirectory();
                break;

            case AssetPath.temporaryCachePath:
                uriString = BundleUtil.GetTemporaryCacheDirectory();
                break;
            }

            this.resources = null;
            if (string.IsNullOrEmpty(bundleDownladerUri))
            {
                return;
            }

            Uri baseUri = new Uri(bundleDownladerUri);

            this.downloader = new WWWDownloader(baseUri, false);
        }
コード例 #6
0
ファイル: AssetLoader.cs プロジェクト: hermitsgame/hotdemo
        public void check()
        {
            var  dir      = BundleUtil.GetStorableDirectory() + name + "/";
            var  nv       = version.Split('.');
            bool nv_vaild = nv.Length >= 2;
            int  nm       = Convert.ToInt32(nv [0]);
            int  nn       = Convert.ToInt32(nv [1]);

            bool clean = true;
            bool up    = true;
            var  file  = dir + "version.txt";

            if (File.Exists(file))
            {
                var  old      = File.ReadAllText(file);
                var  ov       = old.Split('.');
                bool ov_valid = ov.Length >= 2;
                int  om       = Convert.ToInt32(ov [0]);
                int  on       = Convert.ToInt32(ov [1]);

                if (ov_valid && om == nm)
                {
                    clean = false;
                }

                if (ov_valid && on >= nn)
                {
                    up = false;
                }
            }

            shouldClean  = clean;
            shouldUpdate = up;
        }
コード例 #7
0
        IResources GetResources()
        {
            if (this.resources != null)
            {
                return(this.resources);
            }

            /* Create a BundleManifestLoader. */
            IBundleManifestLoader manifestLoader = new BundleManifestLoader();

            /* Loads BundleManifest. */
            BundleManifest manifest = manifestLoader.Load(BundleUtil.GetStorableDirectory() + BundleSetting.ManifestFilename);

            //manifest.ActiveVariants = new string[] { "", "sd" };
            //manifest.ActiveVariants = new string[] { "", "hd" };

            /* Create a PathInfoParser. */
            IPathInfoParser pathInfoParser = new AutoMappingPathInfoParser(manifest);

            /* Use a custom BundleLoaderBuilder */
            ILoaderBuilder builder = new CustomBundleLoaderBuilder(new Uri(BundleUtil.GetReadOnlyDirectory()), false);

            /* Create a BundleManager */
            IBundleManager manager = new BundleManager(manifest, builder);

            /* Create a BundleResources */
            this.resources = new BundleResources(pathInfoParser, manager);
            return(this.resources);
        }
コード例 #8
0
        /// <summary>
        /// 依赖关系解析
        /// </summary>
        /// <param name="bundles"></param>
        /// <returns></returns>
        protected override bool ResolveDependent(IList <AbstractBundle> bundles)
        {
            // 构造解析树
            ResolverTree tree = ResolverTree.Parse(framework, this, bundles);

            // 如果构造失败,则清空集合,解析失败
            if (tree == null)
            {
                bundles.Clear();
                return(false);
            }
            // 获取有序的已解析的插件类表
            IList <AbstractBundle> newBundles = tree.QueryBundlesInOrder();

            if (newBundles == null || newBundles.Count == 0)
            {
                bundles.Clear();
                return(false);
            }
            // 清空当前集合列表
            bundles.Clear();
            BundleUtil.Combine(bundles, newBundles);

            return(true);
        }
コード例 #9
0
        protected virtual IEnumerator DoAnalyzeDownloadList(IProgressPromise <float, List <BundleInfo> > promise, BundleManifest manifest)
        {
            List <BundleInfo> downloads = new List <BundleInfo>();

            BundleInfo[] bundleInfos = manifest.GetAll();
            float        last        = Time.realtimeSinceStartup;
            int          length      = bundleInfos.Length;

            for (int i = 0; i < bundleInfos.Length; i++)
            {
                BundleInfo info = bundleInfos[i];
                if (Time.realtimeSinceStartup - last > 0.15f)
                {
                    yield return(null);

                    last = Time.realtimeSinceStartup;
                }
                promise.UpdateProgress(i + 1 / (float)length);
                if (BundleUtil.Exists(info))
                {
                    continue;
                }

                downloads.Add(info);
            }
            promise.SetResult(downloads);
        }
コード例 #10
0
        public override BundleLoader Create(BundleManager manager, BundleInfo bundleInfo, BundleLoader[] dependencies)
        {
            //Customize the rules for finding assets.

            Uri loadBaseUri = this.BaseUri; //eg: http://your ip/bundles

            if (this.useCache && BundleUtil.ExistsInCache(bundleInfo))
            {
                //Load assets from the cache of Unity3d.
                loadBaseUri = this.BaseUri;
#if UNITY_5_4_OR_NEWER
                return(new UnityWebRequestBundleLoader(new Uri(loadBaseUri, bundleInfo.Filename), bundleInfo, dependencies, manager, this.useCache));
#else
                return(new WWWBundleLoader(new Uri(loadBaseUri, bundleInfo.Filename), bundleInfo, dependencies, manager, this.useCache));
#endif
            }

            if (BundleUtil.ExistsInStorableDirectory(bundleInfo))
            {
                //Load assets from the "Application.persistentDataPath/bundles" folder.
                /* Path: Application.persistentDataPath + "/bundles/" + bundleInfo.Filename  */
                loadBaseUri = new Uri(BundleUtil.GetStorableDirectory());
            }

#if !UNITY_WEBGL || UNITY_EDITOR
            else if (BundleUtil.ExistsInReadOnlyDirectory(bundleInfo))
            {
                //Load assets from the "Application.streamingAssetsPath/bundles" folder.
                /* Path: Application.streamingAssetsPath + "/bundles/" + bundleInfo.Filename */

                loadBaseUri = new Uri(BundleUtil.GetReadOnlyDirectory());
            }
#endif

            if (bundleInfo.IsEncrypted)
            {
                if (this.decryptor != null && bundleInfo.Encoding.Equals(decryptor.AlgorithmName))
                {
                    return(new CryptographBundleLoader(new Uri(loadBaseUri, bundleInfo.Filename), bundleInfo, dependencies, manager, decryptor));
                }

                throw new NotSupportedException(string.Format("Not support the encryption algorithm '{0}'.", bundleInfo.Encoding));
            }


            //Loads assets from an Internet address if it does not exist in the local directory.
#if UNITY_5_4_OR_NEWER
            if (this.IsRemoteUri(loadBaseUri))
            {
                return(new UnityWebRequestBundleLoader(new Uri(loadBaseUri, bundleInfo.Filename), bundleInfo, dependencies, manager, this.useCache));
            }
            else
            {
                return(new FileAsyncBundleLoader(new Uri(loadBaseUri, bundleInfo.Filename), bundleInfo, dependencies, manager));
            }
#else
            return(new WWWBundleLoader(new Uri(loadBaseUri, bundleInfo.Filename), bundleInfo, dependencies, manager, this.useCache));
#endif
        }
コード例 #11
0
ファイル: AssetLoader.cs プロジェクト: hermitsgame/hotdemo
        public void clean()
        {
            var dir = BundleUtil.GetStorableDirectory() + name + "/";

            if (Directory.Exists(dir))
            {
                Directory.Delete(dir, true);
                Directory.CreateDirectory(dir);
            }
        }
コード例 #12
0
ファイル: Launcher.cs プロジェクト: hermitsgame/hotdemo
        IResources CreateResources()
        {
            IResources resources = null;

#if UNITY_EDITOR
            if (SimulationSetting.IsSimulationMode)
            {
                Debug.Log("Use SimulationResources. Run In Editor");

                /* Create a PathInfoParser. */
                //IPathInfoParser pathInfoParser = new SimplePathInfoParser("@");
                IPathInfoParser pathInfoParser = new SimulationAutoMappingPathInfoParser();

                /* Create a BundleManager */
                IBundleManager manager = new SimulationBundleManager();

                /* Create a BundleResources */
                resources = new SimulationResources(pathInfoParser, manager);
            }
            else
#endif
            {
                /* Create a BundleManifestLoader. */
                IBundleManifestLoader manifestLoader = new BundleManifestLoader();

                /* Loads BundleManifest. */
                BundleManifest manifest = manifestLoader.Load(BundleUtil.GetReadOnlyDirectory() + BundleSetting.ManifestFilename);

                //manifest.ActiveVariants = new string[] { "", "sd" };
                manifest.ActiveVariants = new string[] { "", "hd" };

                /* Create a PathInfoParser. */
                //IPathInfoParser pathInfoParser = new SimplePathInfoParser("@");
                IPathInfoParser pathInfoParser = new AutoMappingPathInfoParser(manifest);

                /* Create a BundleLoaderBuilder */
                //ILoaderBuilder builder = new WWWBundleLoaderBuilder(new Uri(BundleUtil.GetReadOnlyDirectory()), false);

                /* AES128_CBC_PKCS7 */
                //RijndaelCryptograph rijndaelCryptograph = new RijndaelCryptograph(128, Encoding.ASCII.GetBytes(this.key), Encoding.ASCII.GetBytes(this.iv));
                IStreamDecryptor decryptor = CryptographUtil.GetDecryptor(Algorithm.AES128_CBC_PKCS7, Encoding.ASCII.GetBytes(this.key), Encoding.ASCII.GetBytes(this.iv));

                /* Use a custom BundleLoaderBuilder */
                ILoaderBuilder builder = new CustomBundleLoaderBuilder(new Uri(BundleUtil.GetReadOnlyDirectory()), false, decryptor);

                /* Create a BundleManager */
                IBundleManager manager = new BundleManager(manifest, builder);

                /* Create a BundleResources */
                resources = new BundleResources(pathInfoParser, manager);
            }
            return(resources);
        }
コード例 #13
0
ファイル: AssetLoader.cs プロジェクト: hermitsgame/hotdemo
    void SaveVersion(string name, string version)
    {
        var v    = BundleUtil.GetStorableDirectory() + name + "/version.txt";
        var info = new FileInfo(v);

        if (info.Exists)
        {
            info.Delete();
        }

        File.WriteAllText(info.FullName, version);
    }
コード例 #14
0
    IResources CreateResources()
    {
        IResources resources = null;

#if UNITY_EDITOR
        if (SimulationSetting.IsSimulationMode)
        {
            LogManager.Log("Use SimulationResources. Run In Editor");

            /* Create a PathInfoParser. */
            //IPathInfoParser pathInfoParser = new SimplePathInfoParser("@");
            IPathInfoParser pathInfoParser = new SimulationAutoMappingPathInfoParser();

            /* Create a BundleManager */
            IBundleManager manager = new SimulationBundleManager();

            /* Create a BundleResources */
            resources = new SimulationResources(pathInfoParser, manager);
        }
        else
#endif
        {
            /* Create a BundleManifestLoader. */
            IBundleManifestLoader manifestLoader = new BundleManifestLoader();


            /* Loads BundleManifest. */
            BundleManifest manifest;
            manifest = manifestLoader.Load(BundleUtil.GetStorableDirectory() + BundleSetting.ManifestFilename);

            //manifest.ActiveVariants = new string[] { "", "sd" };
            //manifest.ActiveVariants = new string[] { "", "hd" };

            /* Create a PathInfoParser. */
            //IPathInfoParser pathInfoParser = new SimplePathInfoParser("@");
            IPathInfoParser pathInfoParser = new AutoMappingPathInfoParser(manifest);

            /* Create a BundleLoaderBuilder */
            ILoaderBuilder builder;
            builder = new WWWComplexLoaderBuilder(new Uri(BundleUtil.GetStorableDirectory()), false);

            /* Create a BundleManager */
            IBundleManager manager = new BundleManager(manifest, builder);

            /* Create a BundleResources */
            resources = new BundleResources(pathInfoParser, manager);
        }
        return(resources);
    }
コード例 #15
0
        void OnGUI()
        {
            if (!downloading)
            {
                GUILayout.Space(20);
                GUILayout.BeginHorizontal();
                GUILayout.Space(20);
                GUILayout.BeginVertical();
                if (GUILayout.Button("Clear persistentDataPath"))
                {
#if UNITY_2017_1_OR_NEWER
                    Caching.ClearCache();
#else
                    Caching.CleanCache();
#endif
                    BundleUtil.ClearStorableDirectory();
                }
#if UNITY_EDITOR
                if (GUILayout.Button("Remove StreamingAssets"))
                {
                    if (Directory.Exists(BundleUtil.GetReadOnlyDirectory()))
                    {
                        Directory.Delete(BundleUtil.GetReadOnlyDirectory(), true);
                    }
                    UnityEditor.AssetDatabase.Refresh();
                }
#endif
                GUILayout.Space(5);
                if (GUILayout.Button("Download AssetBundle"))
                {
                    StartCoroutine(Download());
                }

                if (GUILayout.Button("Load an asset"))
                {
                    if (!File.Exists(BundleUtil.GetStorableDirectory() + BundleSetting.ManifestFilename))
                    {
                        Debug.LogFormat("Please download assetbundles first,try again.");
                    }
                    else
                    {
                        this.LoadAsset("LoxodonFramework/BundleExamples/Models/Red/Red.prefab");
                    }
                }
                GUILayout.EndVertical();
                GUILayout.EndHorizontal();
            }
        }
コード例 #16
0
        public IdentifiedData History(string resourceType, string id)
        {
            this.ThrowIfNotReady();
            try
            {
                var handler = ResourceHandlerUtil.Current.GetResourceHandler(resourceType);

                if (handler != null)
                {
                    String since     = WebOperationContext.Current.IncomingRequest.UriTemplateMatch.QueryParameters["_since"];
                    Guid   sinceGuid = since != null?Guid.Parse(since) : Guid.Empty;

                    // Query
                    var retVal = handler.Get(Guid.Parse(id), Guid.Empty) as IVersionedEntity;
                    List <IVersionedEntity> histItm = new List <IVersionedEntity>()
                    {
                        retVal
                    };
                    while (retVal.PreviousVersionKey.HasValue)
                    {
                        retVal = handler.Get(Guid.Parse(id), retVal.PreviousVersionKey.Value) as IVersionedEntity;
                        if (retVal != null)
                        {
                            histItm.Add(retVal);
                        }
                        // Should we stop fetching?
                        if (retVal?.VersionKey == sinceGuid)
                        {
                            break;
                        }
                    }

                    // Lock the item
                    return(BundleUtil.CreateBundle(histItm.OfType <IdentifiedData>(), histItm.Count, 0, false));
                }
                else
                {
                    throw new FileNotFoundException(resourceType);
                }
            }
            catch (Exception e)
            {
                var remoteEndpoint = OperationContext.Current.IncomingMessageProperties[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty;
                this.m_traceSource.TraceEvent(TraceEventType.Error, e.HResult, String.Format("{0} - {1}", remoteEndpoint?.Address, e.ToString()));
                throw;
            }
        }
コード例 #17
0
ファイル: BuildVM.cs プロジェクト: hermitsgame/hotdemo
 public virtual void ClearFromStreamingAssets()
 {
     try
     {
         AssetDatabase.StartAssetEditing();
         DirectoryInfo dir = new DirectoryInfo(BundleUtil.GetReadOnlyDirectory());
         if (dir.Exists)
         {
             dir.Delete(true);
         }
         AssetDatabase.Refresh();
     }
     finally
     {
         AssetDatabase.StopAssetEditing();
     }
 }
コード例 #18
0
        void Start()
        {
#if UNITY_WEBGL && !UNITY_EDITOR
            Uri baseUri = new Uri(BundleUtil.GetReadOnlyDirectory());
#else
            DirectoryInfo dir = new DirectoryInfo("./AssetBundles/StandaloneWindows/1.0.0/");

            if (!dir.Exists)
            {
                Debug.LogFormat("Directory '{0}' does not exist.", dir.FullName);
                return;
            }

            Uri baseUri = new Uri(dir.FullName);
#endif
            this.downloader = new WWWDownloader(baseUri, false);
        }
コード例 #19
0
ファイル: AssetLoader.cs プロジェクト: hermitsgame/hotdemo
    public IEnumerator LoadGame(string name)
    {
        if (!gamesMap.ContainsKey(name))
        {
            Debug.Log("load game not found: " + name);
            yield break;
        }

#if UNITY_EDITOR
        if (SimulationSetting.IsSimulationMode)
        {
            var ret = simulator.LoadBundle(name + "lua");
            yield return(ret.WaitForDone());

            yield break;
        }
#endif

        Debug.Log("enter LoadGame " + name);

        var cfg = gamesMap[name];

        IBundleManifestLoader manifestLoader = new BundleManifestLoader();

        var path = BundleUtil.GetStorableDirectory() + name + "/";
        var mani = path + BundleSetting.ManifestFilename;

        BundleManifest  manifest       = manifestLoader.Load(mani);
        IPathInfoParser pathInfoParser = new AutoMappingPathInfoParser(manifest);
        ILoaderBuilder  builder        = new CustomBundleLoaderBuilder(new Uri(path), false);

        IBundleManager manager = new BundleManager(manifest, builder);

        var rc = new BundleResources(pathInfoParser, manager);

        cfg.resources = rc;

        var result = rc.LoadBundle(name + "lua");
        yield return(result.WaitForDone());

        cfg.luaBundle = result.Result as DefaultBundle;

        Debug.Log("leave LoadGame " + name);
    }
コード例 #20
0
        IResources CreateResources(BundleManifest manifest)
        {
            IResources resources = null;

#if UNITY_EDITOR
            if (SimulationSetting.IsSimulationMode)
            {
                Debug.Log("Use SimulationResources. Run In Editor");

                /* Create a PathInfoParser. */
                //IPathInfoParser pathInfoParser = new SimplePathInfoParser("@");
                IPathInfoParser pathInfoParser = new SimulationAutoMappingPathInfoParser();

                /* Create a BundleManager */
                IBundleManager manager = new SimulationBundleManager();

                /* Create a BundleResources */
                resources = new SimulationResources(pathInfoParser, manager);
            }
            else
#endif
            {
                /* Create a PathInfoParser. */
                //IPathInfoParser pathInfoParser = new SimplePathInfoParser("@");
                IPathInfoParser pathInfoParser = new AutoMappingPathInfoParser(manifest);

                /* Create a BundleLoaderBuilder */
                //ILoaderBuilder builder = new WWWBundleLoaderBuilder(new Uri(BundleUtil.GetReadOnlyDirectory()), false);

                /* AES128_CBC_PKCS7 */
                RijndaelCryptograph rijndaelCryptograph = new RijndaelCryptograph(128, Encoding.ASCII.GetBytes(this.key), Encoding.ASCII.GetBytes(this.iv));

                /* Use a custom BundleLoaderBuilder */
                ILoaderBuilder builder = new CustomBundleLoaderBuilder(new Uri(BundleUtil.GetReadOnlyDirectory()), false, rijndaelCryptograph);

                /* Create a BundleManager */
                IBundleManager manager = new BundleManager(manifest, builder);

                /* Create a BundleResources */
                resources = new BundleResources(pathInfoParser, manager);
            }
            return(resources);
        }
コード例 #21
0
        /**
         * Build an array of all installed bundles to be launch.
         * The returned array is sorted by increasing startlevel/id order.
         * @param bundles - the bundles installed in the framework
         * @return A sorted array of bundles
         */
        internal AbstractBundle[] GetInstalledBundles(BundleRepository bundles, bool sortByDependency)
        {
            /* make copy of bundles vector in case it is modified during launch */
            AbstractBundle[] installedBundles;

            lock (bundles)
            {
                IList allBundles = bundles.GetBundles();
                installedBundles = new AbstractBundle[allBundles.Count];
                allBundles.CopyTo(installedBundles, 0);

                /* Sort bundle array in ascending startlevel / bundle id order
                 * so that bundles are started in ascending order.
                 */
                BundleUtil.Sort(installedBundles, 0, installedBundles.Length);
                //if (sortByDependency)
                //    SortByDependency(installedBundles);
            }
            return(installedBundles);
        }
コード例 #22
0
        IEnumerator Start()
        {
            ApplicationContext context = Context.GetApplicationContext();

            /* Create a BundleManifestLoader. */
            IBundleManifestLoader manifestLoader = new BundleManifestLoader();

            /* Loads BundleManifest. */
            IAsyncResult <BundleManifest> result = manifestLoader.LoadAsync(BundleUtil.GetReadOnlyDirectory() + BundleSetting.ManifestFilename);

            yield return(result.WaitForDone());

            BundleManifest manifest = result.Result;

            //manifest.ActiveVariants = new string[] { "", "sd" };
            manifest.ActiveVariants = new string[] { "", "hd" };

            this.resources = CreateResources(manifest);
            context.GetContainer().Register <IResources>(this.resources);
        }
コード例 #23
0
        void Awake()
        {
            /* Create a BundleManifestLoader. */
            IBundleManifestLoader manifestLoader = new BundleManifestLoader();

            /* Loads BundleManifest. */
            BundleManifest manifest = manifestLoader.Load(BundleUtil.GetReadOnlyDirectory() + BundleSetting.ManifestFilename);

            /* Create a PathInfoParser. */
            IPathInfoParser pathInfoParser = new AutoMappingPathInfoParser(manifest);

            /* Use a BundleLoaderBuilder */
            ILoaderBuilder builder = new CustomBundleLoaderBuilder(new Uri(BundleUtil.GetReadOnlyDirectory()), false, new RijndaelCryptograph(128, Encoding.ASCII.GetBytes(key), Encoding.ASCII.GetBytes(iv)));

            /* Create a BundleManager */
            IBundleManager manager = new BundleManager(manifest, builder);

            /* Create a BundleResources */
            resources = new BundleResources(pathInfoParser, manager);
        }
コード例 #24
0
ファイル: SystemBundleData.cs プロジェクト: zhaoyin/officeOBA
        /// <summary>
        /// 加载系统插件清单
        /// </summary>
        /// <returns></returns>
        private static XBundle LoadSystemBundleManifest()
        {
            try
            {
                Type   type = typeof(SystemBundleData);
                string xml  = BundleUtil.LoadResourceString(ConfigConstant.SYSTEM_MANIFEST, type.Assembly);

                if (string.IsNullOrEmpty(xml))
                {
                    return(null);
                }
                var xManifest = XBundle.Parse(xml) as XBundle;

                return(xManifest);
            }
            catch (Exception e)
            {
                Log.Debug(e);
            }
            return(null);
        }
コード例 #25
0
ファイル: ResolverTree.cs プロジェクト: zhaoyin/officeOBA
        /// <summary>
        /// 获取有序的依赖插件序列
        /// </summary>
        /// <returns></returns>
        public IList <AbstractBundle> QueryBundlesInOrder()
        {
            if (resolvers.Count == 0)
            {
                return(null);
            }
            // 创建插件列表
            IList <AbstractBundle> bundles    = new List <AbstractBundle>();
            IList <ResolverNode>   lResolvers = new List <ResolverNode>();

            // 获取当前所有解析的跟节点
            ResolverNode[] resolverBundles = new ResolverNode[leafResolverBundles.Count];
            leafResolverBundles.Values.CopyTo(resolverBundles, 0);
            BundleUtil.Sort(resolverBundles, 0, resolverBundles.Length);
            // 放入有序队列中
            Combine(bundles, resolverBundles);
            // 解析下一个层次
            ScanBundlesByOrder(bundles, resolverBundles);

            return(bundles);
        }
コード例 #26
0
        void Start()
        {
#if UNITY_WEBGL && !UNITY_EDITOR
            Uri baseUri = new Uri(BundleUtil.GetReadOnlyDirectory());
#elif UNITY_EDITOR
            DirectoryInfo dir = new DirectoryInfo(string.Format("./AssetBundles/{0}/1.0.0/", UnityEditor.EditorUserBuildSettings.activeBuildTarget));

            if (!dir.Exists)
            {
                Debug.LogFormat("The '{0}' directory does not exist, please make sure the path is correct and the assetbundle file exists in the directory.", dir.FullName);
                return;
            }

            Uri baseUri = new Uri(dir.FullName);

            //If you want to test downloading asset bundles from a remote server, please comment the above code, using the code below
            //Uri baseUri = new Uri("http://your server/platform/bundles/");
#else
            Uri baseUri = new Uri("http://your server/platform/bundles/");
#endif
            this.downloader = new WWWDownloader(baseUri, false);
        }
コード例 #27
0
        void Awake()
        {
            /* Create a BundleManifestLoader. */
            IBundleManifestLoader manifestLoader = new BundleManifestLoader();

            /* Loads BundleManifest. */
            BundleManifest manifest = manifestLoader.Load(BundleUtil.GetReadOnlyDirectory() + BundleSetting.ManifestFilename);

            /* Create a PathInfoParser. */
            IPathInfoParser pathInfoParser = new AutoMappingPathInfoParser(manifest);

            IStreamDecryptor decryptor = CryptographUtil.GetDecryptor(Algorithm.AES128_CBC_PKCS7, Encoding.ASCII.GetBytes(this.key), Encoding.ASCII.GetBytes(this.iv));

            /* Use a BundleLoaderBuilder */
            ILoaderBuilder builder = new CustomBundleLoaderBuilder(new Uri(BundleUtil.GetReadOnlyDirectory()), false, decryptor);

            /* Create a BundleManager */
            IBundleManager manager = new BundleManager(manifest, builder);

            /* Create a BundleResources */
            resources = new BundleResources(pathInfoParser, manager);
        }
コード例 #28
0
    public void Init(Action callback)
    {
        // 初始化 Bundle Uri 下载地址
#if UNITY_EDITOR
        DirectoryInfo dir = new DirectoryInfo(ConfigurationController.Instance.BundleUri);
        if (!dir.Exists)
        {
            LogManager.Log("Directory '{0}' does not exist.", dir.FullName);
            return;
        }
        else
        {
            LogManager.Log("初始化 Bundle Uri 下载地址 ", dir.FullName);
        }
        Uri baseUri = new Uri(dir.FullName);
        this.downloader = new WWWDownloader(baseUri, false);
#elif UNITY_IOS
        // 正式资源 Uri 从服务器获取
        // ...
#elif UNITY_ANDROID
        // 正式资源 Uri 从服务器获取
        // ...
#endif
        if (File.Exists(BundleUtil.GetStorableDirectory() + BundleSetting.ManifestFilename))
        {
            IResources _resources = CreateResources();
            context.GetContainer().Register <IResources>(_resources);
            if (callback != null)
            {
                callback.Invoke();
            }
        }
        else
        {
            StartCoroutine(_CopyManifestFromStreamingAssets(callback));
        }
    }
コード例 #29
0
        /// <summary>
        /// 宿主、片段插件关系解析
        /// </summary>
        /// <param name="bundles"></param>
        protected override void ResolveRelation(IList <AbstractBundle> bundles)
        {
            // 检查数据不完整的插件
            IList <AbstractBundle> removalPendings = new List <AbstractBundle>();

            foreach (AbstractBundle bundle in bundles)
            {
                // 检查当前插件是否为宿主插件,如果是宿主插件直接跳过
                if (!bundle.IsFragment)
                {
                    continue;
                }
                // 获取当前片段插件依赖的宿主插件的唯一标识名和版本号
                string  hostSymbolicName = bundle.BundleData.HostBundleSymbolicName;
                Version version          = bundle.BundleData.HostBundleVersion;
                // 获取宿主插件
                AbstractBundle hostBundle = framework.Bundles.GetBundle(hostSymbolicName, version);
                // 验证宿主插件,以下情况标识片段插件无法附加并解析失败
                // 1. 未找到宿主插件,无法附加,解析失败
                // 2. 找到插件是片段插件,无法附加,解析失败
                // 3. 找到的插件,在数据有效性解析过程中,解析失败,无法附加
                if (hostBundle == null || hostBundle.IsFragment ||
                    hostBundle.ResolveState == (ResolveState.Resolved | ResolveState.Fault))
                {
                    bundle.ResolveState = ResolveState.Resolved | ResolveState.Fault;
                    removalPendings.Add(bundle);
                }
                else
                {
                    // 将片段插件附加到宿主插件中
                    ((BundleFragment)bundle).AddHost(hostBundle as BundleHost);
                    removalPendings.Add(bundle);
                }
            }
            // 将片段插件从当前待解析插件列表中移除
            BundleUtil.Remove <AbstractBundle>(bundles, removalPendings);
        }
コード例 #30
0
ファイル: BuildVM.cs プロジェクト: hermitsgame/hotdemo
        public virtual void CopyToStreamingAssets()
        {
            try
            {
                AssetDatabase.StartAssetEditing();
                BundleBuilder builder = new BundleBuilder();

                DirectoryInfo src  = new DirectoryInfo(builder.GetVersionOutput(this.OutputPath, this.BuildTarget, this.DataVersion));
                DirectoryInfo dest = new DirectoryInfo(BundleUtil.GetReadOnlyDirectory());

                if (dest.Exists)
                {
                    dest.Delete(true);
                }
                if (!dest.Exists)
                {
                    dest.Create();
                }

                BundleManifest manifest = builder.CopyAssetBundleAndManifest(src, dest);
                if (manifest != null)
                {
                    Debug.LogFormat("Copy AssetBundles success.");
                }

                AssetDatabase.Refresh();
            }
            catch (Exception e)
            {
                Debug.LogFormat("Copy AssetBundles failure. Error:{0}", e);
            }
            finally
            {
                AssetDatabase.StopAssetEditing();
            }
        }