mirror of https://github.com/tuyoogame/YooAsset
parent
d354db382c
commit
636fbed7f2
|
@ -132,6 +132,7 @@ namespace YooAsset.Editor
|
|||
{
|
||||
typeof(PackSeparately),
|
||||
typeof(PackDirectory),
|
||||
typeof(PackTopDirectory),
|
||||
typeof(PackCollector),
|
||||
typeof(PackGrouper),
|
||||
typeof(PackRawFile),
|
||||
|
|
|
@ -479,7 +479,19 @@ namespace YooAsset.Editor
|
|||
|
||||
if (collector.IsValid() && collector.NotWriteToAssetList == false)
|
||||
{
|
||||
var collectAssetInfos = collector.GetAllCollectAssets(grouper);
|
||||
List<CollectAssetInfo> collectAssetInfos = null;
|
||||
|
||||
try
|
||||
{
|
||||
collectAssetInfos = collector.GetAllCollectAssets(grouper);
|
||||
}
|
||||
catch(System.Exception e)
|
||||
{
|
||||
Debug.LogError(e.ToString());
|
||||
}
|
||||
|
||||
if(collectAssetInfos != null)
|
||||
{
|
||||
foreach (var collectAssetInfo in collectAssetInfos)
|
||||
{
|
||||
VisualElement elementRow = new VisualElement();
|
||||
|
@ -504,6 +516,7 @@ namespace YooAsset.Editor
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private void AddCollectorBtn_clicked()
|
||||
{
|
||||
var selectGrouper = _grouperListView.selectedItem as AssetBundleGrouper;
|
||||
|
|
|
@ -7,30 +7,64 @@ namespace YooAsset.Editor
|
|||
/// <summary>
|
||||
/// 以文件路径作为资源包名
|
||||
/// 注意:每个文件独自打资源包
|
||||
/// 例如:收集器路径为 "Assets/UIPanel"
|
||||
/// 例如:"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>
|
||||
public class PackSeparately : IPackRule
|
||||
{
|
||||
string IPackRule.GetBundleName(PackRuleData data)
|
||||
{
|
||||
return StringUtility.RemoveExtension(data.AssetPath); //"Assets/Config/test.txt" --> "Assets/Config/test"
|
||||
return StringUtility.RemoveExtension(data.AssetPath);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 以父类文件夹路径作为资源包名
|
||||
/// 注意:文件夹下所有文件打进一个资源包
|
||||
/// 例如:收集器路径为 "Assets/UIPanel"
|
||||
/// 例如:"Assets/UIPanel/Shop/Image/backgroud.png" --> "assets/uipanel/shop/image.bundle"
|
||||
/// 例如:"Assets/UIPanel/Shop/View/main.prefab" --> "assets/uipanel/shop/view.bundle"
|
||||
/// </summary>
|
||||
public class PackDirectory : IPackRule
|
||||
{
|
||||
string IPackRule.GetBundleName(PackRuleData data)
|
||||
{
|
||||
return Path.GetDirectoryName(data.AssetPath); //"Assets/Config/test.txt" --> "Assets/Config"
|
||||
return Path.GetDirectoryName(data.AssetPath);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 以收集器路径下顶级文件夹为资源包名
|
||||
/// 注意:文件夹下所有文件打进一个资源包
|
||||
/// 例如:收集器路径为 "Assets/UIPanel"
|
||||
/// 例如:"Assets/UIPanel/Shop/Image/backgroud.png" --> "assets/uipanel/shop.bundle"
|
||||
/// 例如:"Assets/UIPanel/Shop/View/main.prefab" --> "assets/uipanel/shop.bundle"
|
||||
/// </summary>
|
||||
public class PackTopDirectory : IPackRule
|
||||
{
|
||||
string IPackRule.GetBundleName(PackRuleData data)
|
||||
{
|
||||
string assetPath = data.AssetPath.Replace(data.CollectPath, string.Empty);
|
||||
assetPath = assetPath.TrimStart('/');
|
||||
string[] splits = assetPath.Split('/');
|
||||
if (splits.Length > 0)
|
||||
{
|
||||
if (Path.HasExtension(splits[0]))
|
||||
throw new Exception($"Not found root directory : {assetPath}");
|
||||
string bundleName = $"{data.CollectPath}/{splits[0]}";
|
||||
return bundleName;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"Not found root directory : {assetPath}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 以收集器路径作为资源包名
|
||||
/// 注意:收集器下所有文件打进一个资源包
|
||||
/// 注意:收集的所有文件打进一个资源包
|
||||
/// </summary>
|
||||
public class PackCollector : IPackRule
|
||||
{
|
||||
|
@ -42,7 +76,7 @@ namespace YooAsset.Editor
|
|||
|
||||
/// <summary>
|
||||
/// 以分组名称作为资源包名
|
||||
/// 注意:分组内所有文件打进一个资源包
|
||||
/// 注意:收集的所有文件打进一个资源包
|
||||
/// </summary>
|
||||
public class PackGrouper : IPackRule
|
||||
{
|
||||
|
|
|
@ -582,19 +582,5 @@ namespace YooAsset.Editor
|
|||
return content.Substring(startIndex + key.Length);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 玩家偏好
|
||||
// 枚举
|
||||
public static void PlayerSetEnum<T>(string key, T value)
|
||||
{
|
||||
string enumName = value.ToString();
|
||||
EditorPrefs.SetString(key, enumName);
|
||||
}
|
||||
public static T PlayerGetEnum<T>(string key, T defaultValue)
|
||||
{
|
||||
string enumName = EditorPrefs.GetString(key, defaultValue.ToString());
|
||||
return StringUtility.NameToEnum<T>(enumName);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue