update yooasset2.0

This commit is contained in:
hevinci
2023-09-20 16:09:52 +08:00
parent 880b6d429d
commit 01cf9ccd54
369 changed files with 6557 additions and 5490 deletions

View File

@@ -36,9 +36,9 @@ namespace YooAsset.Editor
public string AssetGUID { private set; get; }
/// <summary>
/// 是否为原生资源
/// 资源类型
/// </summary>
public bool IsRawAsset { private set; get; }
public System.Type AssetType { private set; get; }
/// <summary>
/// 是否为着色器资源
@@ -50,11 +50,6 @@ namespace YooAsset.Editor
/// </summary>
public readonly List<string> AssetTags = new List<string>();
/// <summary>
/// 资源包的分类标签
/// </summary>
public readonly List<string> BundleTags = new List<string>();
/// <summary>
/// 依赖的所有资源
/// 注意:包括零依赖资源和冗余资源(资源包名无效)
@@ -62,17 +57,16 @@ namespace YooAsset.Editor
public List<BuildAssetInfo> AllDependAssetInfos { private set; get; }
public BuildAssetInfo(ECollectorType collectorType, string bundleName, string address, string assetPath, bool isRawAsset)
public BuildAssetInfo(ECollectorType collectorType, string bundleName, string address, string assetPath)
{
CollectorType = collectorType;
BundleName = bundleName;
Address = address;
AssetPath = assetPath;
IsRawAsset = isRawAsset;
AssetGUID = UnityEditor.AssetDatabase.AssetPathToGUID(assetPath);
System.Type assetType = UnityEditor.AssetDatabase.GetMainAssetTypeAtPath(assetPath);
if (assetType == typeof(UnityEngine.Shader) || assetType == typeof(UnityEngine.ShaderVariantCollection))
AssetType = UnityEditor.AssetDatabase.GetMainAssetTypeAtPath(assetPath);
if (AssetType == typeof(UnityEngine.Shader) || AssetType == typeof(UnityEngine.ShaderVariantCollection))
IsShaderAsset = true;
else
IsShaderAsset = false;
@@ -82,11 +76,10 @@ namespace YooAsset.Editor
CollectorType = ECollectorType.None;
Address = string.Empty;
AssetPath = assetPath;
IsRawAsset = false;
AssetGUID = UnityEditor.AssetDatabase.AssetPathToGUID(assetPath);
System.Type assetType = UnityEditor.AssetDatabase.GetMainAssetTypeAtPath(assetPath);
if (assetType == typeof(UnityEngine.Shader) || assetType == typeof(UnityEngine.ShaderVariantCollection))
AssetType = UnityEditor.AssetDatabase.GetMainAssetTypeAtPath(assetPath);
if (AssetType == typeof(UnityEngine.Shader) || AssetType == typeof(UnityEngine.ShaderVariantCollection))
IsShaderAsset = true;
else
IsShaderAsset = false;
@@ -96,7 +89,7 @@ namespace YooAsset.Editor
/// <summary>
/// 设置所有依赖的资源
/// </summary>
public void SetAllDependAssetInfos(List<BuildAssetInfo> dependAssetInfos)
public void SetDependAssetInfos(List<BuildAssetInfo> dependAssetInfos)
{
if (AllDependAssetInfos != null)
throw new System.Exception("Should never get here !");
@@ -123,32 +116,6 @@ namespace YooAsset.Editor
}
}
/// <summary>
/// 添加资源包的分类标签
/// 说明:传染算法统计到的分类标签
/// </summary>
public void AddBundleTags(List<string> tags)
{
foreach (var tag in tags)
{
if (BundleTags.Contains(tag) == false)
{
BundleTags.Add(tag);
}
}
}
/// <summary>
/// 资源包名是否存在
/// </summary>
public bool HasBundleName()
{
if (string.IsNullOrEmpty(BundleName))
return false;
else
return true;
}
/// <summary>
/// 添加关联的资源包名称
/// </summary>
@@ -162,33 +129,14 @@ namespace YooAsset.Editor
}
/// <summary>
/// 计算共享资源包的完整包名
/// 资源包名是否存在
/// </summary>
public void CalculateShareBundleName(ISharedPackRule sharedPackRule, bool uniqueBundleName, string packageName, string shadersBundleName)
public bool HasBundleName()
{
if (CollectorType != ECollectorType.None)
return;
if (IsRawAsset)
throw new Exception("Should never get here !");
if (IsShaderAsset)
{
BundleName = shadersBundleName;
}
if (string.IsNullOrEmpty(BundleName))
return false;
else
{
if (_referenceBundleNames.Count > 1)
{
PackRuleResult packRuleResult = sharedPackRule.GetPackRuleResult(AssetPath);
BundleName = packRuleResult.GetShareBundleName(packageName, uniqueBundleName);
}
else
{
// 注意被引用次数小于1的资源不需要设置资源包名称
BundleName = string.Empty;
}
}
return true;
}
/// <summary>