TH1/Unity/Assets/Scripts/TH1_Logic/Editor/YooAsset/TH1AddressByBundleResourcesPath.cs
2026-06-10 11:58:18 +08:00

29 lines
947 B
C#

using System;
using YooAsset.Editor;
namespace TH1_Logic.Editor.YooAssetTools
{
[DisplayName("定位地址: TH1 BundleResources 路径")]
public class TH1AddressByBundleResourcesPath : IAddressRule
{
private const string BundleResourceRoot = "Assets/BundleResources/";
public string GetAssetAddress(AddressRuleData data)
{
var assetPath = data.AssetPath.Replace('\\', '/');
var collectPath = data.CollectPath.Replace('\\', '/').TrimEnd('/') + "/";
if (assetPath.StartsWith(BundleResourceRoot, StringComparison.OrdinalIgnoreCase))
{
assetPath = assetPath.Substring(BundleResourceRoot.Length);
}
else if (assetPath.StartsWith(collectPath, StringComparison.OrdinalIgnoreCase))
{
assetPath = assetPath.Substring(collectPath.Length);
}
return assetPath;
}
}
}