public static void ValidateModifier(
NodeData node,
BuildTarget target,
IEnumerable <PerformGraph.AssetGroups> incoming,
Action <Type, Type, AssetReference> multipleAssetTypeFound,
Action noModiferData,
Action failedToCreateModifier,
Action <Type, Type> incomingTypeMismatch
)
{
Type expectedType = null;
if (incoming != null)
{
expectedType = TypeUtility.FindFirstIncomingAssetType(incoming);
if (expectedType != null)
{
foreach (var ag in incoming)
{
foreach (var assets in ag.assetGroups.Values)
{
foreach (var a in assets)
{
Type assetType = a.filterType;
if (assetType != expectedType)
{
multipleAssetTypeFound(expectedType, assetType, a);
}
}
}
}
}
}
if (string.IsNullOrEmpty(node.InstanceData[target]))
{
noModiferData();
}
var modifier = ModifierUtility.CreateModifier(node, target);
if (null == modifier)
{
failedToCreateModifier();
}
// if there is no incoming assets, there is no way to check if
// right type of asset is coming in - so we'll just skip the test
// expectedType is not null when there is at least one incoming asset
if (incoming != null && expectedType != null)
{
var targetType = ModifierUtility.GetModifierTargetType(modifier);
if (targetType != expectedType)
{
incomingTypeMismatch(targetType, expectedType);
}
}
}