Beispiel #1
0
        private static void ApplyAssetBundleName(AssetManagement assetManagement, AssetInfoManifest manifest)
        {
            var projectFolders = ProjectFolders.Instance;

            var externalResourcesPath = projectFolders.ExternalResourcesPath;
            var shareResourcesPath    = projectFolders.ShareResourcesPath;

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

            var count = assetInfos.Length;

            using (new AssetEditingScope())
            {
                for (var i = 0; i < count; i++)
                {
                    var assetInfo = assetInfos[i];

                    var apply = false;

                    if (assetInfo.IsAssetBundle)
                    {
                        var assetPath = ExternalResources.GetAssetPathFromAssetInfo(externalResourcesPath, shareResourcesPath, assetInfo);

                        apply = assetManagement.SetAssetBundleName(assetPath, assetInfo.AssetBundle.AssetBundleName);
                    }

                    if (apply)
                    {
                        EditorUtility.DisplayProgressBar("ApplyAssetBundleName", assetInfo.ResourcePath, (float)i / count);
                    }
                }
            }

            EditorUtility.ClearProgressBar();
        }
Beispiel #2
0
        private void UpdateAssetInfo(string[] targetAssetPaths)
        {
            var refresh = false;

            using (new AssetEditingScope())
            {
                for (var i = 0; i < targetAssetPaths.Length; i++)
                {
                    var targetAssetPath = targetAssetPaths[i];

                    // アセット情報収集.
                    var infos = assetManagement.GetAssetInfos(targetAssetPath);

                    foreach (var info in infos)
                    {
                        var assetDir  = info.Category == ExternalResources.ShareCategoryName ? shareResourcesPath : externalResourcesPath;
                        var assetPath = PathUtility.Combine(assetDir, info.ResourcePath);

                        EditorUtility.DisplayProgressBar("Update asset info", info.ResourcePath, (float)i / targetAssetPaths.Length);

                        if (info.AssetBundle == null)
                        {
                            continue;
                        }

                        var assetBundleName = info.AssetBundle.AssetBundleName;

                        // アセットバンドル名適用.
                        refresh |= assetManagement.SetAssetBundleName(assetPath, assetBundleName);
                    }
                }

                EditorUtility.ClearProgressBar();
            }

            if (refresh)
            {
                AssetDatabase.SaveAssets();
                AssetDatabase.Refresh();
            }
        }