[feat] 添加跨平台资源收集
parent
cc75594747
commit
6488e96127
|
@ -46,6 +46,16 @@ namespace YooAsset.Editor
|
||||||
public string AssetTags = string.Empty;
|
public string AssetTags = string.Empty;
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 可寻址路径
|
||||||
|
/// </summary>
|
||||||
|
public string Address = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 跨平台
|
||||||
|
/// </summary>
|
||||||
|
public bool IsMultiPlatform = false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 收集器是否有效
|
/// 收集器是否有效
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -160,6 +170,20 @@ namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
if (IsValidateAsset(assetPath) && IsCollectAsset(assetPath))
|
if (IsValidateAsset(assetPath) && 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)
|
if (result.ContainsKey(assetPath) == false)
|
||||||
{
|
{
|
||||||
var collectAssetInfo = CreateCollectAssetInfo(command, group, assetPath, isRawAsset);
|
var collectAssetInfo = CreateCollectAssetInfo(command, group, assetPath, isRawAsset);
|
||||||
|
@ -281,7 +305,7 @@ namespace YooAsset.Editor
|
||||||
return string.Empty;
|
return string.Empty;
|
||||||
|
|
||||||
IAddressRule addressRuleInstance = AssetBundleCollectorSettingData.GetAddressRuleInstance(AddressRuleName);
|
IAddressRule addressRuleInstance = AssetBundleCollectorSettingData.GetAddressRuleInstance(AddressRuleName);
|
||||||
string adressValue = addressRuleInstance.GetAssetAddress(new AddressRuleData(assetPath, CollectPath, group.GroupName));
|
string adressValue = addressRuleInstance.GetAssetAddress(new AddressRuleData(assetPath, CollectPath, group.GroupName, Address, IsMultiPlatform));
|
||||||
return adressValue;
|
return adressValue;
|
||||||
}
|
}
|
||||||
private string GetBundleName(AssetBundleCollectorGroup group, string assetPath)
|
private string GetBundleName(AssetBundleCollectorGroup group, string assetPath)
|
||||||
|
|
|
@ -582,6 +582,18 @@ namespace YooAsset.Editor
|
||||||
label.style.width = 90;
|
label.style.width = 90;
|
||||||
elementBottom.Add(label);
|
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);
|
var popupField = new PopupField<string>(_collectorTypeList, 0);
|
||||||
popupField.name = "PopupField0";
|
popupField.name = "PopupField0";
|
||||||
|
@ -611,6 +623,14 @@ namespace YooAsset.Editor
|
||||||
popupField.style.width = 150;
|
popupField.style.width = 150;
|
||||||
elementBottom.Add(popupField);
|
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();
|
var textField = new TextField();
|
||||||
textField.name = "TextField1";
|
textField.name = "TextField1";
|
||||||
|
@ -674,6 +694,15 @@ namespace YooAsset.Editor
|
||||||
RemoveCollectorBtn_clicked(collector);
|
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
|
// Collector Path
|
||||||
var objectField1 = element.Q<ObjectField>("ObjectField1");
|
var objectField1 = element.Q<ObjectField>("ObjectField1");
|
||||||
objectField1.SetValueWithoutNotify(collectObject);
|
objectField1.SetValueWithoutNotify(collectObject);
|
||||||
|
@ -750,6 +779,15 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// MultiPlatform
|
||||||
|
var IsMultiPlatform = element.Q<Toggle>("IsMultiPlatform");
|
||||||
|
IsMultiPlatform.SetValueWithoutNotify(collector.IsMultiPlatform);
|
||||||
|
IsMultiPlatform.RegisterValueChangedCallback(evt =>
|
||||||
|
{
|
||||||
|
collector.IsMultiPlatform = evt.newValue;
|
||||||
|
AssetBundleCollectorSettingData.ModifyCollector(selectGroup, collector);
|
||||||
|
});
|
||||||
|
|
||||||
// Tags
|
// Tags
|
||||||
var textFiled1 = element.Q<TextField>("TextField1");
|
var textFiled1 = element.Q<TextField>("TextField1");
|
||||||
textFiled1.SetValueWithoutNotify(collector.AssetTags);
|
textFiled1.SetValueWithoutNotify(collector.AssetTags);
|
||||||
|
@ -796,7 +834,7 @@ namespace YooAsset.Editor
|
||||||
if (_enableAddressableToogle.value)
|
if (_enableAddressableToogle.value)
|
||||||
{
|
{
|
||||||
IAddressRule instance = AssetBundleCollectorSettingData.GetAddressRuleInstance(collector.AddressRuleName);
|
IAddressRule instance = AssetBundleCollectorSettingData.GetAddressRuleInstance(collector.AddressRuleName);
|
||||||
AddressRuleData ruleData = new AddressRuleData(collectAssetInfo.AssetPath, collector.CollectPath, group.GroupName);
|
AddressRuleData ruleData = new AddressRuleData(collectAssetInfo.AssetPath, collector.CollectPath, group.GroupName, collector.Address, collector.IsMultiPlatform);
|
||||||
string addressValue = instance.GetAssetAddress(ruleData);
|
string addressValue = instance.GetAssetAddress(ruleData);
|
||||||
showInfo = $"[{addressValue}] {showInfo}";
|
showInfo = $"[{addressValue}] {showInfo}";
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,4 +31,36 @@ namespace YooAsset.Editor
|
||||||
return $"{collectorName}_{fileName}";
|
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}";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -6,12 +6,16 @@ namespace YooAsset.Editor
|
||||||
public string AssetPath;
|
public string AssetPath;
|
||||||
public string CollectPath;
|
public string CollectPath;
|
||||||
public string GroupName;
|
public string GroupName;
|
||||||
|
public string Address;
|
||||||
|
public bool IsMultiPlatform;
|
||||||
|
|
||||||
public AddressRuleData(string assetPath, string collectPath, string groupName)
|
public AddressRuleData(string assetPath, string collectPath, string groupName, string address, bool isMultiPlatform)
|
||||||
{
|
{
|
||||||
AssetPath = assetPath;
|
AssetPath = assetPath;
|
||||||
CollectPath = collectPath;
|
CollectPath = collectPath;
|
||||||
GroupName = groupName;
|
GroupName = groupName;
|
||||||
|
Address = address;
|
||||||
|
IsMultiPlatform = isMultiPlatform;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue