Beispiel #1
0
        // 根据路径得到这个文件夹的名字
        public static string GetFolderName(string path)
        {
            FileInfo fileInfo = new FileInfo(path);
            string   dir      = EPathHelper.AbsoluteToRelativePathWithAssets(fileInfo.DirectoryName);

            string[] results = dir.Split('/');
            string   result  = results[results.Length - 1];

            return(result);
        }
Beispiel #2
0
        /// <summary>
        /// 清除指定Asset路径下的AssetBundleName
        /// </summary>
        public static void _clear_assetbundle_name(string filePath)
        {
            string        assetPath = EPathHelper.AbsoluteToRelativePathWithAssets(filePath);
            AssetImporter importer  = AssetImporter.GetAtPath(assetPath);

            if (importer != null)
            {
                importer.assetBundleName = "";
                importer.SaveAndReimport();
            }
        }
Beispiel #3
0
        /// <summary>
        /// 根据外部名字设置Asset的名字
        /// </summary>
        public static void SetAbNameByParam(string filePath, string abName)
        {
            string        assetPath = EPathHelper.AbsoluteToRelativePathWithAssets(filePath);
            AssetImporter importer  = AssetImporter.GetAtPath(assetPath);

            if (importer != null)
            {
                string assetbundleName = EPathHelper.NormalizePath(abName) + EAssetBundleConst.ASSETBUNDLE_EXTENSION;
                importer.assetBundleName = assetbundleName;
                importer.SaveAndReimport();
            }
            else
            {
                Debug.LogError("找不到对应的路径的资源:" + filePath);
            }
        }
Beispiel #4
0
        /// <summary>
        /// 根据文件的File Path设置Asset的BundleName BundleName=Asset/XX/
        /// </summary>
        public static void SetAbNameByPath(string filePath)
        {
            string        assetPath = EPathHelper.AbsoluteToRelativePathWithAssets(filePath);
            AssetImporter importer  = AssetImporter.GetAtPath(assetPath);

            if (importer != null)
            {
                // 去掉Assets/ 和文件的后缀
                string str = EPathHelper.RemoveAssetsAndSuffixforPath(filePath);
                //Debug.AssertFormat(string.IsNullOrEmpty(importer.assetBundleName), "设置AssetBundle之前她已经有名字了:[{0}]", filePath);
                importer.assetBundleName = str + EAssetBundleConst.ASSETBUNDLE_EXTENSION;
                importer.SaveAndReimport();
            }
            else
            {
                UnityEngine.Debug.LogError("找不到对应的路径的资源:" + filePath);
            }
        }