88 lines
2.9 KiB
C#
88 lines
2.9 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEditor;
|
|
|
|
namespace BFEditor.Resource
|
|
{
|
|
public abstract class BaseDependenciesChecker
|
|
{
|
|
private bool active = true;
|
|
public bool Active{
|
|
get{return active;}
|
|
set{active = value;}
|
|
}
|
|
public List<string> GetAbnormalDenpendencies(string bundleName, string[] allDependencies)
|
|
{
|
|
// 第一次筛选
|
|
List<string> abnormalDependencies = new List<string>();
|
|
foreach(var dependent in allDependencies)
|
|
{
|
|
bool skip = false;
|
|
foreach(var whiteItem in GetWhitePath())
|
|
{
|
|
if(dependent.Contains(whiteItem))
|
|
{
|
|
skip = true;
|
|
break;
|
|
}
|
|
}
|
|
if(skip)
|
|
{
|
|
continue;
|
|
}
|
|
abnormalDependencies.Add(dependent);
|
|
}
|
|
// 第二次筛选
|
|
List<string> subWhiteList = GetDetailWhitePath(bundleName);
|
|
for (var i = abnormalDependencies.Count - 1; i >= 0; i--)
|
|
{
|
|
foreach(var v in subWhiteList)
|
|
{
|
|
if(abnormalDependencies[i].Contains(v))
|
|
{
|
|
abnormalDependencies.RemoveAt(i);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
OnCheck(bundleName, ref abnormalDependencies);
|
|
return abnormalDependencies;
|
|
}
|
|
protected List<string> GetDetailWhitePath(string bundleName)
|
|
{
|
|
Dictionary<string, List<string>> detailWhiteDic = GetDetailWhiteDic();
|
|
List<string> subWhiteList = new List<string>();
|
|
foreach(var k in detailWhiteDic.Keys)
|
|
{
|
|
if(bundleName.Contains(k))
|
|
{
|
|
subWhiteList = detailWhiteDic[k];
|
|
break;
|
|
}
|
|
}
|
|
return subWhiteList;
|
|
}
|
|
public abstract string GetCheckerName();
|
|
public abstract string GetCheckPathPrefix();
|
|
public virtual string[] GetWhitePath()
|
|
{
|
|
string[] whitePath = {
|
|
// "xxxxxxxx",
|
|
};
|
|
return whitePath;
|
|
}
|
|
protected virtual Dictionary<string, List<string>> GetDetailWhiteDic()
|
|
{
|
|
Dictionary<string, List<string>> detailWhiteDic = new Dictionary<string, List<string>>(){
|
|
// {"prefabs/effects/underground_palace",
|
|
// new List<string>(){
|
|
// "prefabs/effects/underground_palace"
|
|
// }
|
|
// },
|
|
};
|
|
return detailWhiteDic;
|
|
}
|
|
public virtual void OnCheck(string bundleName, ref List<string> allDependencies){}
|
|
}
|
|
} |