namespace AlicizaX { public static partial class Utility { /// /// AB实用函数集,主要是路径拼接 /// public static class Asset { /// /// 路径 /// public static class Path { /// /// 打包资源根路径 /// public const string BundlesPath = "Assets/Bundles"; /// /// 打包资源文件夹名称 /// public const string BundlesDirectoryName = "Bundles"; /// /// 打包资源文件夹Scene名称 /// public const string BundlesDirectorySceneName = "Scene"; /// /// 打包资源文件夹Localization名称 /// public const string BundlesDirectoryLocalizationName = "Localization"; /// /// 打包资源文件夹Config名称 /// public const string BundlesDirectoryConfigName = "Config"; /// /// 打包资源文件夹AOTCode名称 /// public const string BundlesDirectoryAOTCodeName = "AOTCode"; /// /// 打包资源文件夹Code名称 /// public const string BundlesDirectoryCodeName = "Code"; /// /// 打包资源文件夹Sound名称 /// public const string BundlesDirectorySoundName = "Sound"; /// /// 打包资源文件夹Prefab名称 /// public const string BundlesDirectoryPrefabName = "Prefabs"; /// /// 打包资源文件夹Video名称 /// public const string BundlesDirectoryVideoName = "Video"; /// /// 打包资源文件夹Image名称 /// public const string BundlesDirectoryImageName = "Image"; /// /// 打包资源文件夹UI名称 /// public const string BundlesDirectoryUIName = "UI"; /// /// 打包资源文件夹Sprite名称 /// public const string BundlesDirectorySpriteName = "Sprite"; /// /// 打包资源文件夹Shader名称 /// public const string BundlesDirectoryShaderName = "Shader"; /// /// 获取文件路径 /// /// 相对于Bundles的路径,不要以/开头 /// 返回拼接好的路径 public static string GetFilePath(string filePath) { return $"{BundlesPath}/{filePath}"; } /// /// 获取图片文件路径 /// /// 相对于Bundles/Image的路径,不要以/开头,需要携带扩展名 /// 返回拼接好的路径 public static string GetImagePath(string filePath) { return GetCategoryFilePath(BundlesDirectoryImageName, filePath); } /// /// 获取视频文件路径 /// /// 相对于Bundles/Video的路径,不要以/开头,需要携带扩展名 /// 返回拼接好的路径 public static string GetVideoPath(string filePath) { return GetCategoryFilePath(BundlesDirectoryVideoName, filePath); } /// /// 获取Sprite文件路径 /// /// 相对于Bundles/Sprite的路径,不要以/开头,需要携带扩展名 /// 返回拼接好的路径 public static string GetSpritePath(string filePath) { return GetCategoryFilePath(BundlesDirectorySpriteName, filePath); } /// /// 获取Sprite文件路径 /// /// 相对于Bundles/Prefabs的路径,不要以/开头,需要携带扩展名 /// 返回拼接好的路径 public static string GetPrefabPath(string filePath) { return GetCategoryFilePath(BundlesDirectoryPrefabName, filePath); } /// /// 获取根据类别文件夹名称和文件路径获得完整文件路径 /// /// 相对于Bundles的类别名称 /// 相对于Bundles的路径,不要以/开头 /// 返回拼接好的路径 public static string GetCategoryFilePath(string category, string filePath) { return $"{BundlesPath}/{category}/{filePath}"; } /// /// 获取配置文件路径 /// /// 相对于Bundles/Config的路径,不要以/开头,需要携带扩展名 /// 文件扩展名称 /// 返回拼接好的路径 public static string GetConfigPath(string fileName, string extension = ".bytes") { return GetCategoryFilePath(BundlesDirectoryConfigName, $"{fileName}{extension}"); } /// /// 获取AOT元数据代码文件路径 /// /// 相对于Bundles/AOTCode的路径,不要以/开头,需要携带扩展名 /// 文件扩展名称 /// 返回拼接好的路径 public static string GetAOTCodePath(string fileName, string extension = ".bytes") { return GetCategoryFilePath(BundlesDirectoryAOTCodeName, $"{fileName}{extension}"); } /// /// 获取代码文件路径 /// /// 相对于Bundles/Code的路径,不要以/开头,需要携带扩展名 /// 文件扩展名称 /// 返回拼接好的路径 public static string GetCodePath(string fileName, string extension = ".bytes") { return GetCategoryFilePath(BundlesDirectoryCodeName, $"{fileName}{extension}"); } /// /// 获取UI文件路径 /// /// UI包名 /// 返回拼接好的路径 public static string GetUIPackagePath(string uiPackageName) { return GetCategoryFilePath(BundlesDirectoryUIName, $"{uiPackageName}/{uiPackageName}"); } /// /// 获取UI文件路径 /// /// UI路径 /// 返回拼接好的路径 public static string GetUIPath(string uiPath) { return GetCategoryFilePath(BundlesDirectoryUIName, uiPath); } /// /// 获取声音文件路径 /// /// 路径包含名称 /// 扩展名称,默认为.mp3 /// 返回拼接好的路径 public static string GetSoundPath(string pathName, string extension = ".mp3") { if (pathName.IndexOf('.') >= 0) { return GetCategoryFilePath(BundlesDirectorySoundName, pathName); } return GetCategoryFilePath(BundlesDirectorySoundName, $"{pathName}{extension}"); } /// /// 获取场景文件路径 /// /// 路径包含名称 /// 扩展名,默认为.unity /// 返回拼接好的路径 public static string GetScenePath(string pathName, string extension = ".unity") { if (pathName.IndexOf('.') >= 0) { return GetCategoryFilePath(BundlesDirectorySceneName, pathName); } return GetCategoryFilePath(BundlesDirectorySceneName, $"{pathName}{extension}"); } /// /// 获取本地化文件路径 /// /// 路径包含名称 /// 文件扩展名 /// 返回拼接好的路径 public static string GetLocalizationPath(string pathName, string extension = ".xml") { if (pathName.IndexOf('.') >= 0) { return GetCategoryFilePath(BundlesDirectoryLocalizationName, pathName); } return GetCategoryFilePath(BundlesDirectoryLocalizationName, $"{pathName}{extension}"); } } } } }