public void Run(string nodeId, string labelToNext, Dictionary<string, List<InternalAssetData>> groupedSources, List<string> alreadyCached, Action<string, string, Dictionary<string, List<InternalAssetData>>, List<string>> Output) { var usedCache = new List<string>(); var outputDict = new Dictionary<string, List<InternalAssetData>>(); // caution if import setting file is exists already or not. var samplingDirectoryPath = FileController.PathCombine(AssetBundleGraphSettings.IMPORTER_SAMPLING_PLACE, nodeId); var sampleAssetPath = string.Empty; ValidateImportSample(samplingDirectoryPath, (string noSampleFolder) => { Debug.LogWarning("importSetting:" + noSampleFolder); }, (string noSampleFile) => { throw new Exception("importSetting error:" + noSampleFile); }, (string samplePath) => { Debug.Log("using import setting:" + samplePath); sampleAssetPath = samplePath; }, (string tooManysample) => { throw new Exception("importSetting error:" + tooManysample); } ); if (groupedSources.Keys.Count == 0) return; var the1stGroupKey = groupedSources.Keys.ToList()[0]; // shrink group to 1 group. if (1 < groupedSources.Keys.Count) Debug.LogWarning("importSetting shrinking group to \"" + the1stGroupKey + "\" forcely."); var inputSources = new List<InternalAssetData>(); foreach (var groupKey in groupedSources.Keys) { inputSources.AddRange(groupedSources[groupKey]); } var importSetOveredAssetsAndUpdatedFlagDict = new Dictionary<InternalAssetData, bool>(); /* check file & setting. if need, apply importSetting to file. */ var samplingAssetImporter = AssetImporter.GetAtPath(sampleAssetPath); var effector = new InternalSamplingImportEffector(samplingAssetImporter); var samplingAssetImporterTypeStr = samplingAssetImporter.GetType().ToString(); foreach (var inputSource in inputSources) { var importer = AssetImporter.GetAtPath(inputSource.importedPath); /* compare type of import setting effector. */ var importerTypeStr = importer.GetType().ToString(); if (importerTypeStr != samplingAssetImporterTypeStr) { throw new OnNodeException("for each importerSetting should be only treat 1 import setting. current import setting type of this node is:" + samplingAssetImporterTypeStr + " inputted error file path:" + inputSource.importedPath, nodeId); } importSetOveredAssetsAndUpdatedFlagDict[inputSource] = false; /* kind of importer is matched. check setting then apply setting or no changed. */ switch (importerTypeStr) { case "UnityEditor.TextureImporter": { var texImporter = importer as TextureImporter; var same = InternalSamplingImportEffector.IsSameTextureSetting(texImporter, samplingAssetImporter as TextureImporter); if (!same) { effector.ForceOnPreprocessTexture(texImporter); importSetOveredAssetsAndUpdatedFlagDict[inputSource] = true; } break; } case "UnityEditor.ModelImporter": { var modelImporter = importer as ModelImporter; var same = InternalSamplingImportEffector.IsSameModelSetting(modelImporter, samplingAssetImporter as ModelImporter); var data = AssetDatabase.LoadAssetAtPath(inputSource.importedPath, inputSource.assetType); if (!same) { effector.ForceOnPreprocessModel(modelImporter); importSetOveredAssetsAndUpdatedFlagDict[inputSource] = true; } break; } case "UnityEditor.AudioImporter": { var audioImporter = importer as AudioImporter; var same = InternalSamplingImportEffector.IsSameAudioSetting(audioImporter, samplingAssetImporter as AudioImporter); if (!same) { effector.ForceOnPreprocessAudio(audioImporter); importSetOveredAssetsAndUpdatedFlagDict[inputSource] = true; } break; } default: { throw new OnNodeException("unhandled importer type:" + importerTypeStr, nodeId); } } } /* inputSetting sequence is over. */ var outputSources = new List<InternalAssetData>(); foreach (var inputAsset in inputSources) { var updated = importSetOveredAssetsAndUpdatedFlagDict[inputAsset]; if (!updated) { // already set completed. var newInternalAssetData = InternalAssetData.InternalAssetDataGeneratedByImporterOrModifierOrPrefabricator( inputAsset.importedPath, AssetDatabase.AssetPathToGUID(inputAsset.importedPath), AssetBundleGraphInternalFunctions.GetAssetType(inputAsset.importedPath), false,// not changed. false ); outputSources.Add(newInternalAssetData); } else { // updated asset. var newInternalAssetData = InternalAssetData.InternalAssetDataGeneratedByImporterOrModifierOrPrefabricator( inputAsset.importedPath, AssetDatabase.AssetPathToGUID(inputAsset.importedPath), AssetBundleGraphInternalFunctions.GetAssetType(inputAsset.importedPath), true,// changed. false ); outputSources.Add(newInternalAssetData); } } outputDict[the1stGroupKey] = outputSources; Output(nodeId, labelToNext, outputDict, usedCache); }
public void Run(string nodeId, string labelToNext, Dictionary <string, List <InternalAssetData> > groupedSources, List <string> alreadyCached, Action <string, string, Dictionary <string, List <InternalAssetData> >, List <string> > Output) { var usedCache = new List <string>(); var outputDict = new Dictionary <string, List <InternalAssetData> >(); // caution if import setting file is exists already or not. var samplingDirectoryPath = FileController.PathCombine(AssetBundleGraphSettings.IMPORTER_SAMPLING_PLACE, nodeId); var sampleAssetPath = string.Empty; ValidateImportSample(samplingDirectoryPath, (string noSampleFolder) => { Debug.LogWarning("importSetting:" + noSampleFolder); }, (string noSampleFile) => { throw new Exception("importSetting error:" + noSampleFile); }, (string samplePath) => { Debug.Log("using import setting:" + samplePath); sampleAssetPath = samplePath; }, (string tooManysample) => { throw new Exception("importSetting error:" + tooManysample); } ); if (groupedSources.Keys.Count == 0) { return; } var the1stGroupKey = groupedSources.Keys.ToList()[0]; // shrink group to 1 group. if (1 < groupedSources.Keys.Count) { Debug.LogWarning("importSetting shrinking group to \"" + the1stGroupKey + "\" forcely."); } var inputSources = new List <InternalAssetData>(); foreach (var groupKey in groupedSources.Keys) { inputSources.AddRange(groupedSources[groupKey]); } var importSetOveredAssetsAndUpdatedFlagDict = new Dictionary <InternalAssetData, bool>(); /* * check file & setting. * if need, apply importSetting to file. */ var samplingAssetImporter = AssetImporter.GetAtPath(sampleAssetPath); var effector = new InternalSamplingImportEffector(samplingAssetImporter); var samplingAssetImporterTypeStr = samplingAssetImporter.GetType().ToString(); foreach (var inputSource in inputSources) { var importer = AssetImporter.GetAtPath(inputSource.importedPath); /* * compare type of import setting effector. */ var importerTypeStr = importer.GetType().ToString(); if (importerTypeStr != samplingAssetImporterTypeStr) { throw new OnNodeException("for each importerSetting should be only treat 1 import setting. current import setting type of this node is:" + samplingAssetImporterTypeStr + " inputted error file path:" + inputSource.importedPath, nodeId); } importSetOveredAssetsAndUpdatedFlagDict[inputSource] = false; /* * kind of importer is matched. * check setting then apply setting or no changed. */ switch (importerTypeStr) { case "UnityEditor.TextureImporter": { var texImporter = importer as TextureImporter; var same = InternalSamplingImportEffector.IsSameTextureSetting(texImporter, samplingAssetImporter as TextureImporter); if (!same) { effector.ForceOnPreprocessTexture(texImporter); importSetOveredAssetsAndUpdatedFlagDict[inputSource] = true; } break; } case "UnityEditor.ModelImporter": { var modelImporter = importer as ModelImporter; var same = InternalSamplingImportEffector.IsSameModelSetting(modelImporter, samplingAssetImporter as ModelImporter); var data = AssetDatabase.LoadAssetAtPath(inputSource.importedPath, inputSource.assetType); if (!same) { effector.ForceOnPreprocessModel(modelImporter); importSetOveredAssetsAndUpdatedFlagDict[inputSource] = true; } break; } case "UnityEditor.AudioImporter": { var audioImporter = importer as AudioImporter; var same = InternalSamplingImportEffector.IsSameAudioSetting(audioImporter, samplingAssetImporter as AudioImporter); if (!same) { effector.ForceOnPreprocessAudio(audioImporter); importSetOveredAssetsAndUpdatedFlagDict[inputSource] = true; } break; } default: { throw new OnNodeException("unhandled importer type:" + importerTypeStr, nodeId); } } } /* * inputSetting sequence is over. */ var outputSources = new List <InternalAssetData>(); foreach (var inputAsset in inputSources) { var updated = importSetOveredAssetsAndUpdatedFlagDict[inputAsset]; if (!updated) { // already set completed. var newInternalAssetData = InternalAssetData.InternalAssetDataGeneratedByImporterOrModifierOrPrefabricator( inputAsset.importedPath, AssetDatabase.AssetPathToGUID(inputAsset.importedPath), AssetBundleGraphInternalFunctions.GetAssetType(inputAsset.importedPath), false, // not changed. false ); outputSources.Add(newInternalAssetData); } else { // updated asset. var newInternalAssetData = InternalAssetData.InternalAssetDataGeneratedByImporterOrModifierOrPrefabricator( inputAsset.importedPath, AssetDatabase.AssetPathToGUID(inputAsset.importedPath), AssetBundleGraphInternalFunctions.GetAssetType(inputAsset.importedPath), true, // changed. false ); outputSources.Add(newInternalAssetData); } } outputDict[the1stGroupKey] = outputSources; Output(nodeId, labelToNext, outputDict, usedCache); }
public void Run(string nodeName, string nodeId, string connectionIdToNextNode, Dictionary <string, List <Asset> > groupedSources, List <string> alreadyCached, Action <string, string, Dictionary <string, List <Asset> >, List <string> > Output) { var usedCache = new List <string>(); var outputDict = new Dictionary <string, List <Asset> >(); // caution if import setting file is exists already or not. var samplingDirectoryPath = FileUtility.PathCombine(AssetBundleGraphSettings.IMPORTER_SETTINGS_PLACE, nodeId); var sampleAssetPath = string.Empty; ValidateImportSample(samplingDirectoryPath, (string samplePath) => { throw new AssetBundleGraphBuildException(nodeName + ": No ImportSettings Directory found for this node:" + nodeName + " please supply assets to this node."); }, (string samplePath) => { throw new AssetBundleGraphBuildException(nodeName + ": No saved ImportSettings found for asset:" + samplePath); }, (string samplePath) => { sampleAssetPath = samplePath; }, (string samplePath) => { throw new AssetBundleGraphBuildException(nodeName + ": Too many ImportSettings found. please open editor and resolve issue:" + samplePath); } ); if (groupedSources.Keys.Count == 0) { return; } var the1stGroupKey = groupedSources.Keys.ToList()[0]; // ImportSetting merges multiple incoming groups into one, so warn this if (1 < groupedSources.Keys.Count) { Debug.LogWarning(nodeName + " ImportSetting merges incoming group into \"" + groupedSources.Keys.ToList()[0]); } var inputSources = new List <Asset>(); foreach (var groupKey in groupedSources.Keys) { inputSources.AddRange(groupedSources[groupKey]); } var assetImportSettingUpdateMap = new Dictionary <Asset, bool>(); /* * check file & setting. * if need, apply importSetting to file. */ var samplingAssetImporter = AssetImporter.GetAtPath(sampleAssetPath); var effector = new InternalSamplingImportEffector(samplingAssetImporter); foreach (var asset in inputSources) { var importer = AssetImporter.GetAtPath(asset.importFrom); if (samplingAssetImporter.GetType() != importer.GetType()) { throw new NodeException("for each importerSetting should be only treat 1 import setting. current import setting type of this node is:" + samplingAssetImporter.GetType().ToString() + " for file:" + asset.importFrom, nodeId); } assetImportSettingUpdateMap[asset] = false; /* * Apply ImporterSettings' preserved settings, and record if anything changed */ switch (importer.GetType().ToString()) { case "UnityEditor.TextureImporter": { var texImporter = importer as TextureImporter; var same = InternalSamplingImportEffector.IsSameTextureSetting(texImporter, samplingAssetImporter as TextureImporter); if (!same) { effector.ForceOnPreprocessTexture(texImporter); assetImportSettingUpdateMap[asset] = true; } break; } case "UnityEditor.ModelImporter": { var modelImporter = importer as ModelImporter; var same = InternalSamplingImportEffector.IsSameModelSetting(modelImporter, samplingAssetImporter as ModelImporter); if (!same) { effector.ForceOnPreprocessModel(modelImporter); assetImportSettingUpdateMap[asset] = true; } break; } case "UnityEditor.AudioImporter": { var audioImporter = importer as AudioImporter; var same = InternalSamplingImportEffector.IsSameAudioSetting(audioImporter, samplingAssetImporter as AudioImporter); if (!same) { effector.ForceOnPreprocessAudio(audioImporter); assetImportSettingUpdateMap[asset] = true; } break; } default: { throw new NodeException("unhandled importer type:" + importer.GetType().ToString(), nodeId); } } } var outputSources = new List <Asset>(); foreach (var asset in inputSources) { var updated = assetImportSettingUpdateMap[asset]; if (!updated) { // already set completed. outputSources.Add( Asset.CreateNewAssetWithImportPathAndStatus( asset.importFrom, false, // isNew not changed. false ) ); } else { // updated asset. outputSources.Add( Asset.CreateNewAssetWithImportPathAndStatus( asset.importFrom, true, // isNew changed. false ) ); } } outputDict[the1stGroupKey] = outputSources; Output(nodeId, connectionIdToNextNode, outputDict, usedCache); }