Beispiel #1
0
        // アセット管理マニュフェスト情報を更新.
        private void SetAssetInfoManifest(AssetInfoManifest manifest)
        {
            assetInfoManifest = manifest;

            if (manifest == null)
            {
                Debug.LogError("AssetInfoManifest not found.");
                return;
            }

            var allAssetInfos = manifest.GetAssetInfos().ToArray();

            // アセット情報 (Key: アセットバンドル名).
            assetInfosByAssetBundleName = allAssetInfos
                                          .Where(x => x.IsAssetBundle)
                                          .ToLookup(x => x.AssetBundle.AssetBundleName);

            // アセット情報 (Key: リソースパス).
            assetInfosByResourcePath = allAssetInfos
                                       .Where(x => !string.IsNullOrEmpty(x.ResourcePath))
                                       .ToDictionary(x => x.ResourcePath);

            // アセットバンドル依存関係.
            var dependencies = allAssetInfos
                               .Where(x => x.IsAssetBundle)
                               .Select(x => x.AssetBundle)
                               .Where(x => x.Dependencies != null && x.Dependencies.Any())
                               .GroupBy(x => x.AssetBundleName)
                               .Select(x => x.FirstOrDefault())
                               .ToDictionary(x => x.AssetBundleName, x => x.Dependencies);

            assetBundleManager.SetDependencies(dependencies);
        }
Beispiel #2
0
        private IEnumerator UpdateManifestInternal()
        {
            var sw = System.Diagnostics.Stopwatch.StartNew();

            // アセット管理情報読み込み.

            var manifestAssetInfo = AssetInfoManifest.GetManifestAssetInfo();

            var assetPath = PathUtility.Combine(resourceDirectory, manifestAssetInfo.ResourcePath);

            // AssetInfoManifestは常に最新に保たなくてはいけない為必ずダウンロードする.
            var loadYield = assetBundleManager.UpdateAssetInfoManifest()
                            .SelectMany(_ => assetBundleManager.LoadAsset <AssetInfoManifest>(manifestAssetInfo, assetPath))
                            .ToYieldInstruction(false);

            while (!loadYield.IsDone)
            {
                yield return(null);
            }

            if (loadYield.HasError || loadYield.IsCanceled)
            {
                yield break;
            }

            SetAssetInfoManifest(loadYield.Result);

            sw.Stop();

            if (LogEnable && UnityConsole.Enable)
            {
                var message = string.Format("UpdateManifest: ({0:F2}ms)", sw.Elapsed.TotalMilliseconds);

                UnityConsole.Event(ConsoleEventName, ConsoleEventColor, message);
            }

            // アセット管理情報を登録.

            assetBundleManager.SetManifest(assetInfoManifest);

            #if ENABLE_CRIWARE_ADX || ENABLE_CRIWARE_SOFDEC
            criAssetManager.SetManifest(assetInfoManifest);
            #endif

            // 不要になったファイル削除.
            var deleteCacheYield = DeleteDisUsedCache().ToYieldInstruction(false);

            while (!deleteCacheYield.IsDone)
            {
                yield return(null);
            }

            if (deleteCacheYield.HasError)
            {
                Debug.LogException(deleteCacheYield.Error);
            }
        }
Beispiel #3
0
        private IEnumerator UpdateManifestInternal(IProgress <float> progress = null)
        {
            var sw = System.Diagnostics.Stopwatch.StartNew();

            // アセット管理情報読み込み.

            var manifestFileName = AssetInfoManifest.ManifestFileName;

            #if UNITY_EDITOR
            if (simulateMode)
            {
                manifestFileName = PathUtility.Combine(resourceDir, manifestFileName);
            }
            #endif

            var manifestAssetInfo = AssetInfoManifest.GetManifestAssetInfo();

            // AssetInfoManifestは常に最新に保たなくてはいけない為必ずダウンロードする.
            var loadYield = assetBundleManager.UpdateAssetInfoManifest()
                            .SelectMany(_ => assetBundleManager.LoadAsset <AssetInfoManifest>(manifestAssetInfo, manifestFileName))
                            .ToYieldInstruction(false);

            yield return(loadYield);

            if (loadYield.HasError || loadYield.IsCanceled)
            {
                yield break;
            }

            SetAssetInfoManifest(loadYield.Result);

            sw.Stop();

            var message = string.Format("UpdateManifest: ({0}ms)", sw.Elapsed.TotalMilliseconds);
            UnityConsole.Event(ConsoleEventName, ConsoleEventColor, message);

            // アセット管理情報を登録.

            assetBundleManager.SetManifest(assetInfoManifest);

            #if ENABLE_CRIWARE_ADX || ENABLE_CRIWARE_SOFDEC
            criAssetManager.SetManifest(assetInfoManifest);
            #endif
        }