namespace YooAsset.Editor { public struct PackRuleData { public string AssetPath; public string CollectPath; public string GroupName; public string UserData; public PackRuleData(string assetPath, string collectPath, string groupName, string userData) { AssetPath = assetPath; CollectPath = collectPath; GroupName = groupName; UserData = userData; } } public struct PackRuleResult { private readonly string _bundleName; private readonly string _bundleExtension; public PackRuleResult(string bundleName, string bundleExtension) { _bundleName = bundleName; _bundleExtension = bundleExtension; } /// /// 结果是否有效 /// public bool IsValid() { return string.IsNullOrEmpty(_bundleName) == false && string.IsNullOrEmpty(_bundleExtension) == false; } /// /// 获取资源包全名称 /// public string GetBundleName(string packageName, bool uniqueBundleName) { string fullName; string bundleName = EditorTools.GetRegularPath(_bundleName).Replace('/', '_').Replace('.', '_').Replace(" ", "_").ToLower(); if (uniqueBundleName) fullName = $"{packageName}_{bundleName}.{_bundleExtension}"; else fullName = $"{bundleName}.{_bundleExtension}"; return fullName.ToLower(); } /// /// 获取共享资源包全名称 /// public string GetShareBundleName(string packageName, bool uniqueBundleName) { string fullName; string bundleName = EditorTools.GetRegularPath(_bundleName).Replace('/', '_').Replace('.', '_').Replace(" ", "_").ToLower(); if (uniqueBundleName) fullName = $"{packageName}_share_{bundleName}.{_bundleExtension}"; else fullName = $"share_{bundleName}.{_bundleExtension}"; return fullName.ToLower(); } } /// /// 资源打包规则接口 /// public interface IPackRule { /// /// 获取打包规则结果 /// PackRuleResult GetPackRuleResult(PackRuleData data); } }