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); } } }
public static void ValidateInputSetting( NodeData node, BuildTarget target, IEnumerable <PerformGraph.AssetGroups> incoming, Action <Type, Type, AssetReference> multipleAssetTypeFound, Action <Type> unsupportedType, Action <Type, Type> incomingTypeMismatch, Action <ConfigStatus> errorInConfig ) { Type expectedType = TypeUtility.FindFirstIncomingAssetType(incoming); if (multipleAssetTypeFound != null) { if (expectedType != null && incoming != 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 (unsupportedType != null) { if (expectedType != null) { if (expectedType == typeof(UnityEditor.TextureImporter) || expectedType == typeof(UnityEditor.ModelImporter) || expectedType == typeof(UnityEditor.AudioImporter) ) { // good. do nothing } else { unsupportedType(expectedType); } } } var status = GetConfigStatus(node); if (errorInConfig != null) { if (status != ConfigStatus.GoodSampleFound) { errorInConfig(status); } } if (incomingTypeMismatch != null) { // 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 if (incoming != null && expectedType != null && status == ConfigStatus.GoodSampleFound) { Type targetType = GetReferenceAssetImporter(node).GetType(); if (targetType != expectedType) { incomingTypeMismatch(targetType, expectedType); } } } }