mirror of https://github.com/tuyoogame/YooAsset
Compare commits
3 Commits
a9f8449d86
...
0dd97e9004
Author | SHA1 | Date |
---|---|---|
absences | 0dd97e9004 | |
absences | 008a3e1893 | |
unknown | fa572e6ae1 |
|
@ -272,19 +272,43 @@ namespace YooAsset.Editor
|
|||
}
|
||||
private List<AssetInfo> GetAllDependencies(CollectCommand command, string mainAssetPath)
|
||||
{
|
||||
string[] depends = AssetDatabase.GetDependencies(mainAssetPath, true);
|
||||
List<AssetInfo> result = new List<AssetInfo>(depends.Length);
|
||||
foreach (string assetPath in depends)
|
||||
List<AssetInfo> dependencies = new List<AssetInfo>();
|
||||
HashSet<AssetStamp> m_AssetStamps = new HashSet<AssetStamp>();
|
||||
void GetDependRecursive(string assetPath)
|
||||
{
|
||||
// 注意:排除主资源对象
|
||||
if (assetPath == mainAssetPath)
|
||||
string[] depends = AssetDatabase.GetDependencies(assetPath, false);
|
||||
|
||||
foreach (string dependPath in depends)
|
||||
{
|
||||
// 注意:排除资源自身
|
||||
if (dependPath == assetPath)
|
||||
continue;
|
||||
//排除主资源
|
||||
if (dependPath == mainAssetPath)
|
||||
continue;
|
||||
|
||||
AssetInfo assetInfo = new AssetInfo(assetPath);
|
||||
if (command.IgnoreRule.IsIgnore(assetInfo) == false)
|
||||
result.Add(assetInfo);
|
||||
var stamp = new AssetStamp(mainAssetPath, dependPath);
|
||||
|
||||
//主资源对于一个资源只有一个依赖
|
||||
if (m_AssetStamps.Contains(stamp))
|
||||
continue;
|
||||
m_AssetStamps.Add(stamp);
|
||||
|
||||
AssetInfo assetInfo = new AssetInfo(dependPath);
|
||||
|
||||
//根据忽略规则排除
|
||||
if (command.IgnoreRule.IsIgnore(assetInfo))
|
||||
continue;
|
||||
|
||||
dependencies.Add(assetInfo);
|
||||
|
||||
GetDependRecursive(dependPath);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
GetDependRecursive(mainAssetPath);
|
||||
|
||||
return dependencies;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[StructLayout(LayoutKind.Auto)]
|
||||
internal struct AssetStamp
|
||||
{
|
||||
private readonly string m_AssetName;
|
||||
private readonly string m_DependAssetPath;
|
||||
|
||||
public AssetStamp(string assetName, string dependencyAssetName)
|
||||
{
|
||||
m_AssetName = assetName;
|
||||
m_DependAssetPath = dependencyAssetName;
|
||||
}
|
||||
|
||||
public string AssetName
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_AssetName;
|
||||
}
|
||||
}
|
||||
|
||||
public string DependAssetPath
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_DependAssetPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue