Beispiel #1
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();
            }
        }
Beispiel #2
0
        private bool UpdateViewInfo(Object assetObject)
        {
            var assetPath = AssetDatabase.GetAssetPath(assetObject);

            var infos = assetManagement.GetAssetInfos(assetPath);

            var info = infos.FirstOrDefault();

            selectionAssetObject = info != null ? assetObject : null;
            assetCategory        = info != null ? info.Category : null;
            assetBundleName      = info != null && info.IsAssetBundle ? info.AssetBundle.AssetBundleName : null;
            assetLoadPath        = string.IsNullOrEmpty(assetPath) ? string.Empty : assetManagement.GetAssetLoadPath(assetPath);

            if (info == null)
            {
                return(false);
            }

            var guid = AssetDatabase.AssetPathToGUID(assetPath);

            Prefs.selectionAssetGUID = guid;

            return(true);
        }