parent
5a98a68c27
commit
157402bb39
|
@ -45,16 +45,11 @@ namespace YooAsset.Editor
|
|||
/// </summary>
|
||||
public string AssetTags = string.Empty;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 可寻址路径
|
||||
/// 用户自定义数据
|
||||
/// </summary>
|
||||
public string Address = string.Empty;
|
||||
public string UserData = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 跨平台
|
||||
/// </summary>
|
||||
public bool IsMultiPlatform = false;
|
||||
|
||||
/// <summary>
|
||||
/// 收集器是否有效
|
||||
|
@ -173,20 +168,6 @@ namespace YooAsset.Editor
|
|||
{
|
||||
if (IsValidateAsset(assetPath, isRawFilePackRule) && IsCollectAsset(assetPath))
|
||||
{
|
||||
if (IsMultiPlatform)
|
||||
{
|
||||
string platform = "Windows";
|
||||
#if UNITY_ANDROID
|
||||
platform = "Android";
|
||||
#elif UNITY_IOS
|
||||
platform = "iOS";
|
||||
#elif UNITY_STANDALONE_OSX
|
||||
platform = "OSX";
|
||||
#endif
|
||||
if (!assetPath.Contains(platform))
|
||||
continue;
|
||||
}
|
||||
|
||||
if (result.ContainsKey(assetPath) == false)
|
||||
{
|
||||
var collectAssetInfo = CreateCollectAssetInfo(command, group, assetPath, isRawFilePackRule);
|
||||
|
@ -329,7 +310,7 @@ namespace YooAsset.Editor
|
|||
return string.Empty;
|
||||
|
||||
IAddressRule addressRuleInstance = AssetBundleCollectorSettingData.GetAddressRuleInstance(AddressRuleName);
|
||||
string adressValue = addressRuleInstance.GetAssetAddress(new AddressRuleData(assetPath, CollectPath, group.GroupName, Address, IsMultiPlatform));
|
||||
string adressValue = addressRuleInstance.GetAssetAddress(new AddressRuleData(assetPath, CollectPath, group.GroupName, UserData));
|
||||
return adressValue;
|
||||
}
|
||||
private string GetBundleName(CollectCommand command, AssetBundleCollectorGroup group, string assetPath)
|
||||
|
@ -345,7 +326,7 @@ namespace YooAsset.Editor
|
|||
{
|
||||
// 获取其它资源打包规则结果
|
||||
IPackRule packRuleInstance = AssetBundleCollectorSettingData.GetPackRuleInstance(PackRuleName);
|
||||
PackRuleResult packRuleResult = packRuleInstance.GetPackRuleResult(new PackRuleData(assetPath, CollectPath, group.GroupName));
|
||||
PackRuleResult packRuleResult = packRuleInstance.GetPackRuleResult(new PackRuleData(assetPath, CollectPath, group.GroupName, UserData));
|
||||
return packRuleResult.GetMainBundleName(command.PackageName, command.UniqueBundleName);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace YooAsset.Editor
|
|||
{
|
||||
public class AssetBundleCollectorConfig
|
||||
{
|
||||
public const string ConfigVersion = "2.2";
|
||||
public const string ConfigVersion = "2.3";
|
||||
|
||||
public const string XmlVersion = "Version";
|
||||
public const string XmlCommon = "Common";
|
||||
|
@ -34,6 +34,7 @@ namespace YooAsset.Editor
|
|||
public const string XmlAddressRule = "AddressRule";
|
||||
public const string XmlPackRule = "PackRule";
|
||||
public const string XmlFilterRule = "FilterRule";
|
||||
public const string XmlUserData = "UserData";
|
||||
public const string XmlAssetTags = "AssetTags";
|
||||
|
||||
/// <summary>
|
||||
|
@ -137,6 +138,8 @@ namespace YooAsset.Editor
|
|||
throw new Exception($"Not found attribute {XmlPackRule} in {XmlCollector}");
|
||||
if (collectorElement.HasAttribute(XmlFilterRule) == false)
|
||||
throw new Exception($"Not found attribute {XmlFilterRule} in {XmlCollector}");
|
||||
if (collectorElement.HasAttribute(XmlUserData) == false)
|
||||
throw new Exception($"Not found attribute {XmlUserData} in {XmlCollector}");
|
||||
if (collectorElement.HasAttribute(XmlAssetTags) == false)
|
||||
throw new Exception($"Not found attribute {XmlAssetTags} in {XmlCollector}");
|
||||
|
||||
|
@ -147,6 +150,7 @@ namespace YooAsset.Editor
|
|||
collector.AddressRuleName = collectorElement.GetAttribute(XmlAddressRule);
|
||||
collector.PackRuleName = collectorElement.GetAttribute(XmlPackRule);
|
||||
collector.FilterRuleName = collectorElement.GetAttribute(XmlFilterRule);
|
||||
collector.UserData = collectorElement.GetAttribute(XmlUserData);
|
||||
collector.AssetTags = collectorElement.GetAttribute(XmlAssetTags);
|
||||
group.Collectors.Add(collector);
|
||||
}
|
||||
|
@ -219,6 +223,7 @@ namespace YooAsset.Editor
|
|||
collectorElement.SetAttribute(XmlAddressRule, collector.AddressRuleName);
|
||||
collectorElement.SetAttribute(XmlPackRule, collector.PackRuleName);
|
||||
collectorElement.SetAttribute(XmlFilterRule, collector.FilterRuleName);
|
||||
collectorElement.SetAttribute(XmlUserData, collector.UserData);
|
||||
collectorElement.SetAttribute(XmlAssetTags, collector.AssetTags);
|
||||
groupElement.AppendChild(collectorElement);
|
||||
}
|
||||
|
@ -320,6 +325,28 @@ namespace YooAsset.Editor
|
|||
return UpdateXmlConfig(xmlDoc);
|
||||
}
|
||||
|
||||
// 2.2 -> 2.3
|
||||
if (configVersion == "2.2")
|
||||
{
|
||||
// 获取所有分组元素
|
||||
var groupNodeList = root.GetElementsByTagName(XmlGroup);
|
||||
foreach (var groupNode in groupNodeList)
|
||||
{
|
||||
XmlElement groupElement = groupNode as XmlElement;
|
||||
var collectorNodeList = groupElement.GetElementsByTagName(XmlCollector);
|
||||
foreach (var collectorNode in collectorNodeList)
|
||||
{
|
||||
XmlElement collectorElement = collectorNode as XmlElement;
|
||||
if (collectorElement.HasAttribute(XmlUserData) == false)
|
||||
collectorElement.SetAttribute(XmlUserData, string.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
// 更新版本
|
||||
root.SetAttribute(XmlVersion, "2.3");
|
||||
return UpdateXmlConfig(xmlDoc);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -108,7 +108,7 @@ namespace YooAsset.Editor
|
|||
List<Type> types = new List<Type>(100)
|
||||
{
|
||||
typeof(AddressByFileName),
|
||||
typeof(AddressByCollectorAndFileName),
|
||||
typeof(AddressByFolderAndFileName),
|
||||
typeof(AddressByGroupAndFileName)
|
||||
};
|
||||
|
||||
|
|
|
@ -582,18 +582,6 @@ namespace YooAsset.Editor
|
|||
label.style.width = 90;
|
||||
elementBottom.Add(label);
|
||||
}
|
||||
{
|
||||
var textField = new TextField();
|
||||
textField.name = "TextField0";
|
||||
textField.label = "Address";
|
||||
textField.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
textField.style.flexGrow = 1f;
|
||||
elementBottom.Add(textField);
|
||||
var label = textField.Q<Label>();
|
||||
textField.style.width = 200;
|
||||
|
||||
label.style.minWidth = 63;
|
||||
}
|
||||
{
|
||||
var popupField = new PopupField<string>(_collectorTypeList, 0);
|
||||
popupField.name = "PopupField0";
|
||||
|
@ -606,14 +594,14 @@ namespace YooAsset.Editor
|
|||
var popupField = new PopupField<RuleDisplayName>(_addressRuleList, 0);
|
||||
popupField.name = "PopupField1";
|
||||
popupField.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
popupField.style.width = 200;
|
||||
popupField.style.width = 220;
|
||||
elementBottom.Add(popupField);
|
||||
}
|
||||
{
|
||||
var popupField = new PopupField<RuleDisplayName>(_packRuleList, 0);
|
||||
popupField.name = "PopupField2";
|
||||
popupField.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
popupField.style.width = 230;
|
||||
popupField.style.width = 220;
|
||||
elementBottom.Add(popupField);
|
||||
}
|
||||
{
|
||||
|
@ -624,12 +612,13 @@ namespace YooAsset.Editor
|
|||
elementBottom.Add(popupField);
|
||||
}
|
||||
{
|
||||
var IsMultiPlatform = new Toggle();
|
||||
IsMultiPlatform.name = "IsMultiPlatform";
|
||||
IsMultiPlatform.text = "MultiPlatform";
|
||||
IsMultiPlatform.style.unityTextAlign = TextAnchor.MiddleCenter;
|
||||
IsMultiPlatform.style.flexGrow = 0f;
|
||||
elementTop.Add(IsMultiPlatform);
|
||||
var textField = new TextField();
|
||||
textField.name = "TextField0";
|
||||
textField.label = "UserData";
|
||||
textField.style.width = 200;
|
||||
elementBottom.Add(textField);
|
||||
var label = textField.Q<Label>();
|
||||
label.style.minWidth = 63;
|
||||
}
|
||||
{
|
||||
var textField = new TextField();
|
||||
|
@ -694,15 +683,6 @@ namespace YooAsset.Editor
|
|||
RemoveCollectorBtn_clicked(collector);
|
||||
};
|
||||
|
||||
// Address
|
||||
var textFiled0 = element.Q<TextField>("TextField0");
|
||||
textFiled0.SetValueWithoutNotify(collector.Address);
|
||||
textFiled0.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
collector.Address = evt.newValue;
|
||||
AssetBundleCollectorSettingData.ModifyCollector(selectGroup, collector);
|
||||
});
|
||||
|
||||
// Collector Path
|
||||
var objectField1 = element.Q<ObjectField>("ObjectField1");
|
||||
objectField1.SetValueWithoutNotify(collectObject);
|
||||
|
@ -779,12 +759,12 @@ namespace YooAsset.Editor
|
|||
}
|
||||
});
|
||||
|
||||
// MultiPlatform
|
||||
var IsMultiPlatform = element.Q<Toggle>("IsMultiPlatform");
|
||||
IsMultiPlatform.SetValueWithoutNotify(collector.IsMultiPlatform);
|
||||
IsMultiPlatform.RegisterValueChangedCallback(evt =>
|
||||
// UserData
|
||||
var textFiled0 = element.Q<TextField>("TextField0");
|
||||
textFiled0.SetValueWithoutNotify(collector.UserData);
|
||||
textFiled0.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
collector.IsMultiPlatform = evt.newValue;
|
||||
collector.UserData = evt.newValue;
|
||||
AssetBundleCollectorSettingData.ModifyCollector(selectGroup, collector);
|
||||
});
|
||||
|
||||
|
@ -834,7 +814,7 @@ namespace YooAsset.Editor
|
|||
if (_enableAddressableToogle.value)
|
||||
{
|
||||
IAddressRule instance = AssetBundleCollectorSettingData.GetAddressRuleInstance(collector.AddressRuleName);
|
||||
AddressRuleData ruleData = new AddressRuleData(collectAssetInfo.AssetPath, collector.CollectPath, group.GroupName, collector.Address, collector.IsMultiPlatform);
|
||||
AddressRuleData ruleData = new AddressRuleData(collectAssetInfo.AssetPath, collector.CollectPath, group.GroupName, collector.UserData);
|
||||
string addressValue = instance.GetAssetAddress(ruleData);
|
||||
showInfo = $"[{addressValue}] {showInfo}";
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[DisplayName("以文件名称为定位地址")]
|
||||
[DisplayName("定位地址: 文件名")]
|
||||
public class AddressByFileName : IAddressRule
|
||||
{
|
||||
string IAddressRule.GetAssetAddress(AddressRuleData data)
|
||||
|
@ -11,7 +11,7 @@ namespace YooAsset.Editor
|
|||
}
|
||||
}
|
||||
|
||||
[DisplayName("以分组名称+文件名称为定位地址")]
|
||||
[DisplayName("定位地址: 分组名+文件名")]
|
||||
public class AddressByGroupAndFileName : IAddressRule
|
||||
{
|
||||
string IAddressRule.GetAssetAddress(AddressRuleData data)
|
||||
|
@ -21,8 +21,8 @@ namespace YooAsset.Editor
|
|||
}
|
||||
}
|
||||
|
||||
[DisplayName("以收集器名称+文件名称为定位地址")]
|
||||
public class AddressByCollectorAndFileName : IAddressRule
|
||||
[DisplayName("定位地址: 文件夹名+文件名")]
|
||||
public class AddressByFolderAndFileName : IAddressRule
|
||||
{
|
||||
string IAddressRule.GetAssetAddress(AddressRuleData data)
|
||||
{
|
||||
|
@ -31,36 +31,4 @@ namespace YooAsset.Editor
|
|||
return $"{collectorName}_{fileName}";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[DisplayName("以Address+文件路径为定位地址")]
|
||||
public class AddressByAddressAndFilePath : IAddressRule
|
||||
{
|
||||
string IAddressRule.GetAssetAddress(AddressRuleData data)
|
||||
{
|
||||
if (Path.HasExtension(data.CollectPath))
|
||||
{
|
||||
return data.Address;
|
||||
}
|
||||
else
|
||||
{
|
||||
string path = data.AssetPath.Replace(data.CollectPath, "");
|
||||
if (data.IsMultiPlatform)
|
||||
{
|
||||
string platform = "Windows";
|
||||
#if UNITY_ANDROID
|
||||
platform = "Android";
|
||||
#elif UNITY_IOS
|
||||
platform = "iOS";
|
||||
#elif UNITY_STANDALONE_OSX
|
||||
platform = "OSX";
|
||||
#endif
|
||||
path = path.Replace($"{platform}/", "");
|
||||
}
|
||||
string fileName = Path.GetFileName(data.AssetPath);
|
||||
return $"{data.Address}{path}";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -35,7 +35,7 @@ namespace YooAsset.Editor
|
|||
/// 例如:"Assets/UIPanel/Shop/Image/backgroud.png" --> "assets_uipanel_shop_image_backgroud.bundle"
|
||||
/// 例如:"Assets/UIPanel/Shop/View/main.prefab" --> "assets_uipanel_shop_view_main.bundle"
|
||||
/// </summary>
|
||||
[DisplayName("以文件路径作为资源包名")]
|
||||
[DisplayName("资源包名: 文件路径")]
|
||||
public class PackSeparately : IPackRule
|
||||
{
|
||||
PackRuleResult IPackRule.GetPackRuleResult(PackRuleData data)
|
||||
|
@ -57,7 +57,7 @@ namespace YooAsset.Editor
|
|||
/// 例如:"Assets/UIPanel/Shop/Image/backgroud.png" --> "assets_uipanel_shop_image.bundle"
|
||||
/// 例如:"Assets/UIPanel/Shop/View/main.prefab" --> "assets_uipanel_shop_view.bundle"
|
||||
/// </summary>
|
||||
[DisplayName("以父类文件夹路径作为资源包名")]
|
||||
[DisplayName("资源包名: 父类文件夹路径")]
|
||||
public class PackDirectory : IPackRule
|
||||
{
|
||||
public static PackDirectory StaticPackRule = new PackDirectory();
|
||||
|
@ -82,7 +82,7 @@ namespace YooAsset.Editor
|
|||
/// 例如:"Assets/UIPanel/Shop/Image/backgroud.png" --> "assets_uipanel_shop.bundle"
|
||||
/// 例如:"Assets/UIPanel/Shop/View/main.prefab" --> "assets_uipanel_shop.bundle"
|
||||
/// </summary>
|
||||
[DisplayName("以收集器路径下顶级文件夹为资源包名")]
|
||||
[DisplayName("资源包名: 收集器下顶级文件夹路径")]
|
||||
public class PackTopDirectory : IPackRule
|
||||
{
|
||||
PackRuleResult IPackRule.GetPackRuleResult(PackRuleData data)
|
||||
|
@ -114,7 +114,7 @@ namespace YooAsset.Editor
|
|||
/// 以收集器路径作为资源包名
|
||||
/// 注意:收集的所有文件打进一个资源包
|
||||
/// </summary>
|
||||
[DisplayName("以收集器路径作为资源包名")]
|
||||
[DisplayName("资源包名: 收集器路径")]
|
||||
public class PackCollector : IPackRule
|
||||
{
|
||||
PackRuleResult IPackRule.GetPackRuleResult(PackRuleData data)
|
||||
|
@ -144,7 +144,7 @@ namespace YooAsset.Editor
|
|||
/// 以分组名称作为资源包名
|
||||
/// 注意:收集的所有文件打进一个资源包
|
||||
/// </summary>
|
||||
[DisplayName("以分组名称作为资源包名")]
|
||||
[DisplayName("资源包名: 分组名称")]
|
||||
public class PackGroup : IPackRule
|
||||
{
|
||||
PackRuleResult IPackRule.GetPackRuleResult(PackRuleData data)
|
||||
|
@ -162,7 +162,6 @@ namespace YooAsset.Editor
|
|||
|
||||
/// <summary>
|
||||
/// 打包原生文件
|
||||
/// 注意:原生文件打包支持:图片,音频,视频,文本
|
||||
/// </summary>
|
||||
[DisplayName("打包原生文件")]
|
||||
public class PackRawFile : IPackRule
|
||||
|
@ -183,7 +182,7 @@ namespace YooAsset.Editor
|
|||
/// <summary>
|
||||
/// 打包着色器变种集合
|
||||
/// </summary>
|
||||
[DisplayName("打包着色器变种集合")]
|
||||
[DisplayName("打包着色器变种集合文件")]
|
||||
public class PackShaderVariants : IPackRule
|
||||
{
|
||||
public PackRuleResult GetPackRuleResult(PackRuleData data)
|
||||
|
|
|
@ -6,16 +6,14 @@ namespace YooAsset.Editor
|
|||
public string AssetPath;
|
||||
public string CollectPath;
|
||||
public string GroupName;
|
||||
public string Address;
|
||||
public bool IsMultiPlatform;
|
||||
public string UserData;
|
||||
|
||||
public AddressRuleData(string assetPath, string collectPath, string groupName, string address, bool isMultiPlatform)
|
||||
public AddressRuleData(string assetPath, string collectPath, string groupName, string userData)
|
||||
{
|
||||
AssetPath = assetPath;
|
||||
CollectPath = collectPath;
|
||||
GroupName = groupName;
|
||||
Address = address;
|
||||
IsMultiPlatform = isMultiPlatform;
|
||||
UserData = userData;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,18 +6,21 @@ namespace YooAsset.Editor
|
|||
public string AssetPath;
|
||||
public string CollectPath;
|
||||
public string GroupName;
|
||||
public string UserData;
|
||||
|
||||
public PackRuleData(string assetPath)
|
||||
{
|
||||
AssetPath = assetPath;
|
||||
CollectPath = string.Empty;
|
||||
GroupName = string.Empty;
|
||||
UserData = string.Empty;
|
||||
}
|
||||
public PackRuleData(string assetPath, string collectPath, string groupName)
|
||||
public PackRuleData(string assetPath, string collectPath, string groupName, string userData)
|
||||
{
|
||||
AssetPath = assetPath;
|
||||
CollectPath = collectPath;
|
||||
GroupName = groupName;
|
||||
UserData = userData;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue