Compare commits

...

2 Commits

Author SHA1 Message Date
BoysheO 5222490f06
Merge 9e2030c83d into cdaa45e163 2024-11-07 11:57:58 +08:00
BoysheO 9e2030c83d
Update DefaultAddressRule.cs
添加一个寻址规则,效果极好
2024-09-10 11:36:46 +08:00
1 changed files with 20 additions and 1 deletions

View File

@ -40,4 +40,23 @@ namespace YooAsset.Editor
return $"{fileInfo.Directory.Name}_{fileName}";
}
}
}
[DisplayName("定位地址: 文件名.智能尾缀")]
public class AddressByFileNameAndExt : IAddressRule
{
public string GetAssetAddress(AddressRuleData data)
{
var ext = Path.GetExtension(data.AssetPath);
if (ext == ".asset")
{
var a = UnityEditor.AssetDatabase.LoadAssetAtPath<UnityEngine.Object>(data.AssetPath);
if (a == null) return ".errortype";
var type = a.GetType();
var dt = Path.GetFileNameWithoutExtension(data.AssetPath);
return dt + $".{type.Name.ToLowerInvariant()}";
}
return Path.GetFileName(data.AssetPath);
}
}
}