public void Setup(string nodeId, string labelToNext, Dictionary <string, List <InternalAssetData> > groupedSources, List <string> alreadyCached, Action <string, string, Dictionary <string, List <InternalAssetData> >, List <string> > Output) { var outputDict = new Dictionary <string, List <InternalAssetData> >(); var first = true; if (groupedSources.Keys.Count == 0) { return; } // shrink group to 1 group. if (1 < groupedSources.Keys.Count) { Debug.LogWarning("modifierSetting shrinking group to \"" + groupedSources.Keys.ToList()[0] + "\" forcely."); } var inputSources = new List <InternalAssetData>(); foreach (var groupKey in groupedSources.Keys) { inputSources.AddRange(groupedSources[groupKey]); } var assumedImportedAssetDatas = new List <InternalAssetData>(); var samplingDirectoryPath = FileController.PathCombine(AssetBundleGraphSettings.MODIFIER_SAMPLING_PLACE, nodeId); ValidateModifierSample(samplingDirectoryPath, (string noSampleFolder) => { // do nothing. keep importing new asset for sampling. }, (string noSampleFile) => { // do nothing. keep importing new asset for sampling. }, (string samplePath) => { first = false; }, (string tooManysample) => { first = false; } ); var alreadyImported = new List <string>(); var ignoredResource = new List <string>(); foreach (var inputSource in inputSources) { if (string.IsNullOrEmpty(inputSource.absoluteSourcePath)) { if (!string.IsNullOrEmpty(inputSource.importedPath)) { alreadyImported.Add(inputSource.importedPath); continue; } ignoredResource.Add(inputSource.fileNameAndExtension); continue; } var assumedType = TypeBinder.AssumeTypeOfAsset(inputSource.importedPath); var newData = InternalAssetData.InternalAssetDataByImporter( inputSource.traceId, inputSource.absoluteSourcePath, inputSource.sourceBasePath, inputSource.fileNameAndExtension, inputSource.pathUnderSourceBase, inputSource.importedPath, null, assumedType ); assumedImportedAssetDatas.Add(newData); if (first) { if (!Directory.Exists(samplingDirectoryPath)) { Directory.CreateDirectory(samplingDirectoryPath); } var absoluteFilePath = inputSource.absoluteSourcePath; var targetFilePath = FileController.PathCombine(samplingDirectoryPath, inputSource.fileNameAndExtension); EditorUtility.DisplayProgressBar("AssetBundleGraph Modifier generating ModifierSetting...", targetFilePath, 0); FileController.CopyFileFromGlobalToLocal(absoluteFilePath, targetFilePath); first = false; AssetDatabase.Refresh(ImportAssetOptions.ImportRecursive); EditorUtility.ClearProgressBar(); } if (alreadyImported.Any()) { Debug.LogError("modifierSetting:" + string.Join(", ", alreadyImported.ToArray()) + " are already imported."); } if (ignoredResource.Any()) { Debug.LogError("modifierSetting:" + string.Join(", ", ignoredResource.ToArray()) + " are ignored."); } outputDict[groupedSources.Keys.ToList()[0]] = assumedImportedAssetDatas; } Output(nodeId, labelToNext, outputDict, new List <string>()); }
public void Setup(string nodeId, string labelToNext, Dictionary <string, List <InternalAssetData> > groupedSources, List <string> alreadyCached, Action <string, string, Dictionary <string, List <InternalAssetData> >, List <string> > Output) { // reserve importSetting type for limit asset. var importSettingSampleType = string.Empty; var outputDict = new Dictionary <string, List <InternalAssetData> >(); var first = true; if (groupedSources.Keys.Count == 0) { return; } // shrink group to 1 group. if (1 < groupedSources.Keys.Count) { Debug.LogWarning("importSetting shrinking group to \"" + groupedSources.Keys.ToList()[0] + "\" forcely."); } var inputSources = new List <InternalAssetData>(); foreach (var groupKey in groupedSources.Keys) { inputSources.AddRange(groupedSources[groupKey]); } var assumedImportedAssetDatas = new List <InternalAssetData>(); var samplingDirectoryPath = FileController.PathCombine(AssetBundleGraphSettings.IMPORTER_SAMPLING_PLACE, nodeId); ValidateImportSample(samplingDirectoryPath, (string noSampleFolder) => { // do nothing. keep importing new asset for sampling. }, (string noSampleFile) => { // do nothing. keep importing new asset for sampling. }, (string samplePath) => { importSettingSampleType = AssetImporter.GetAtPath(samplePath).GetType().ToString(); first = false; }, (string tooManysample) => { throw new OnNodeException("too many sampling file found. please clear ImportSettingSamples folder.", nodeId); } ); var alreadyImported = new List <string>(); var ignoredResource = new List <string>(); foreach (var inputSource in inputSources) { if (string.IsNullOrEmpty(inputSource.absoluteSourcePath)) { if (!string.IsNullOrEmpty(inputSource.importedPath)) { alreadyImported.Add(inputSource.importedPath); continue; } ignoredResource.Add(inputSource.fileNameAndExtension); continue; } var assumedImportedPath = inputSource.importedPath; var assumedType = AssetImporter.GetAtPath(assumedImportedPath).GetType(); var importerTypeStr = assumedType.ToString(); /* * only texture, model and audio importer is acceptable. */ switch (importerTypeStr) { case "UnityEditor.TextureImporter": case "UnityEditor.ModelImporter": case "UnityEditor.AudioImporter": { break; } default: { throw new OnNodeException("unhandled importer type:" + importerTypeStr, nodeId); } } var newData = InternalAssetData.InternalAssetDataByImporter( inputSource.traceId, inputSource.absoluteSourcePath, inputSource.sourceBasePath, inputSource.fileNameAndExtension, inputSource.pathUnderSourceBase, assumedImportedPath, null, assumedType ); assumedImportedAssetDatas.Add(newData); if (first) { if (!Directory.Exists(samplingDirectoryPath)) { Directory.CreateDirectory(samplingDirectoryPath); } var absoluteFilePath = inputSource.absoluteSourcePath; var targetFilePath = FileController.PathCombine(samplingDirectoryPath, inputSource.fileNameAndExtension); EditorUtility.DisplayProgressBar("AssetBundleGraph ImportSetting generating ImporterSetting...", targetFilePath, 0); FileController.CopyFileFromGlobalToLocal(absoluteFilePath, targetFilePath); first = false; AssetDatabase.Refresh(ImportAssetOptions.ImportRecursive); EditorUtility.ClearProgressBar(); importSettingSampleType = AssetImporter.GetAtPath(targetFilePath).GetType().ToString(); } else { if (importerTypeStr != importSettingSampleType) { throw new OnNodeException("for each importerSetting should be only treat 1 import setting. current import setting type of this node is:" + importSettingSampleType + " inputted error file path:" + inputSource.importedPath, nodeId); } } if (alreadyImported.Any()) { Debug.LogError("importSetting:" + string.Join(", ", alreadyImported.ToArray()) + " are already imported."); } if (ignoredResource.Any()) { Debug.LogError("importSetting:" + string.Join(", ", ignoredResource.ToArray()) + " are ignored."); } outputDict[groupedSources.Keys.ToList()[0]] = assumedImportedAssetDatas; } Output(nodeId, labelToNext, outputDict, new List <string>()); }