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.MODIFIER_SAMPLING_PLACE, nodeId); var sampleAssetPath = string.Empty; ValidateModifierSample(samplingDirectoryPath, (string noSampleFolder) => { Debug.LogWarning("modifierSetting:" + noSampleFolder); }, (string noSampleFile) => { throw new Exception("modifierSetting error:" + noSampleFile); }, (string samplePath) => { Debug.Log("using modifier setting:" + samplePath); sampleAssetPath = samplePath; }, (string tooManysample) => { throw new Exception("modifierSetting 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("modifierSetting 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 modifierSetting to file. */ { var samplingAssetImporter = AssetImporter.GetAtPath(sampleAssetPath); var effector = new InternalSamplingImportEffector(samplingAssetImporter); { foreach (var inputSource in inputSources) { var importer = AssetImporter.GetAtPath(inputSource.importedPath); /* * compare type of import setting effector. */ var importerTypeStr = importer.GetType().ToString(); if (importerTypeStr != samplingAssetImporter.GetType().ToString()) { // mismatched target will be ignored. but already imported. importSetOveredAssetsAndUpdatedFlagDict[inputSource] = false; continue; } importSetOveredAssetsAndUpdatedFlagDict[inputSource] = false; /* * kind of importer is matched. * check setting then apply setting or no changed. */ switch (importerTypeStr) { case "UnityEditor.AssetImporter": { // materials and others... assets which are generated in Unity. // Modifier is under development. do nothing in this node yet. // importSetOveredAssetsAndUpdatedFlagDict[inputSource] = true; break; } default: { throw new Exception("unhandled modifier type:" + importerTypeStr); } } } } } /* * 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 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); }
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.MODIFIER_SAMPLING_PLACE, nodeId); var sampleAssetPath = string.Empty; ValidateModifierSample(samplingDirectoryPath, (string noSampleFolder) => { Debug.LogWarning("modifierSetting:" + noSampleFolder); }, (string noSampleFile) => { throw new Exception("modifierSetting error:" + noSampleFile); }, (string samplePath) => { Debug.Log("using modifier setting:" + samplePath); sampleAssetPath = samplePath; }, (string tooManysample) => { throw new Exception("modifierSetting 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("modifierSetting 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 modifierSetting to file. */ { var samplingAssetImporter = AssetImporter.GetAtPath(sampleAssetPath); var effector = new InternalSamplingImportEffector(samplingAssetImporter); { foreach (var inputSource in inputSources) { var importer = AssetImporter.GetAtPath(inputSource.importedPath); /* * compare type of import setting effector. */ var importerTypeStr = importer.GetType().ToString(); if (importerTypeStr != samplingAssetImporter.GetType().ToString()) { // mismatched target will be ignored. but already imported. importSetOveredAssetsAndUpdatedFlagDict[inputSource] = false; continue; } importSetOveredAssetsAndUpdatedFlagDict[inputSource] = false; /* * kind of importer is matched. * check setting then apply setting or no changed. */ switch (importerTypeStr) { case "UnityEditor.AssetImporter": { // materials and others... assets which are generated in Unity. var assetType = inputSource.assetType.ToString(); switch (assetType) { case "UnityEngine.Material": { // 判別はできるんだけど、このあとどうしたもんか。ロードしなきゃいけない + loadしてもなんかグローバルなプロパティだけ比較とかそういうのかなあ、、 // var materialInstance = AssetDatabase.LoadAssetAtPath(inputSource.importedPath, inputSource.assetType) as Material;// 型を指定してロードしないといけないので、ここのコードのようにswitchに落としたほうが良さそう。 // var s = materialInstance.globalIlluminationFlags;// グローバルなプロパティ、リフレクションで列挙できそうではあるけど、、、 break; } default: { Debug.LogError("unsupported type. assetType:" + assetType); break; } } /* * 試しにserializeして云々してみる */ var assetInstance = AssetDatabase.LoadAssetAtPath(inputSource.importedPath, inputSource.assetType) as Material; // ここの型が露出しちゃうのやばい var serializedObject = new UnityEditor.SerializedObject(assetInstance); var itr = serializedObject.GetIterator(); itr.NextVisible(true); // Debug.LogError("0 itr:" + itr.propertyPath + " displayName:" + itr.displayName + " name:" + itr.name + " type:" + itr.type); // while (itr.NextVisible(true)) { // Debug.LogError("~ itr:" + itr.propertyPath + " displayName:" + itr.displayName + " name:" + itr.name + " type:" + itr.type); // } /* * このへんのログはこんな感じになる。 * * 0 itr:m_Shader displayName:Shader name:m_Shader type:PPtr<Shader> * ~ itr:m_ShaderKeywords displayName:Shader Keywords name:m_ShaderKeywords type:string * ~ itr:m_LightmapFlags displayName:Lightmap Flags name:m_LightmapFlags type:uint * ~ itr:m_CustomRenderQueue displayName:Custom Render Queue name:m_CustomRenderQueue type:int * ~ itr:stringTagMap displayName:String Tag Map name:stringTagMap type:map * ~ itr:stringTagMap.Array.size displayName:Size name:size type:ArraySize * ~ itr:m_SavedProperties displayName:Saved Properties name:m_SavedProperties type:UnityPropertySheet * ~ itr:m_SavedProperties.m_TexEnvs displayName:Tex Envs name:m_TexEnvs type:map * ~ itr:m_SavedProperties.m_TexEnvs.Array.size displayName:Size name:size type:ArraySize * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[0] displayName:Element 0 name:data type:pair * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[0].first displayName:First name:first type:FastPropertyName * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[0].first.name displayName:Name name:name type:string * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[0].second displayName:Second name:second type:UnityTexEnv * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[0].second.m_Texture displayName:Texture name:m_Texture type:PPtr<Texture> * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[0].second.m_Scale displayName:Scale name:m_Scale type:Vector2 * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[0].second.m_Scale.x displayName:X name:x type:float * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[0].second.m_Scale.y displayName:Y name:y type:float * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[0].second.m_Offset displayName:Offset name:m_Offset type:Vector2 * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[0].second.m_Offset.x displayName:X name:x type:float * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[0].second.m_Offset.y displayName:Y name:y type:float * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[1] displayName:Element 1 name:data type:pair * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[1].first displayName:First name:first type:FastPropertyName * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[1].first.name displayName:Name name:name type:string * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[1].second displayName:Second name:second type:UnityTexEnv * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[1].second.m_Texture displayName:Texture name:m_Texture type:PPtr<Texture> * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[1].second.m_Scale displayName:Scale name:m_Scale type:Vector2 * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[1].second.m_Scale.x displayName:X name:x type:float * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[1].second.m_Scale.y displayName:Y name:y type:float * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[1].second.m_Offset displayName:Offset name:m_Offset type:Vector2 * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[1].second.m_Offset.x displayName:X name:x type:float * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[1].second.m_Offset.y displayName:Y name:y type:float * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[2] displayName:Element 2 name:data type:pair * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[2].first displayName:First name:first type:FastPropertyName * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[2].first.name displayName:Name name:name type:string * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[2].second displayName:Second name:second type:UnityTexEnv * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[2].second.m_Texture displayName:Texture name:m_Texture type:PPtr<Texture> * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[2].second.m_Scale displayName:Scale name:m_Scale type:Vector2 * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[2].second.m_Scale.x displayName:X name:x type:float * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[2].second.m_Scale.y displayName:Y name:y type:float * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[2].second.m_Offset displayName:Offset name:m_Offset type:Vector2 * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[2].second.m_Offset.x displayName:X name:x type:float * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[2].second.m_Offset.y displayName:Y name:y type:float * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[3] displayName:Element 3 name:data type:pair * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[3].first displayName:First name:first type:FastPropertyName * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[3].first.name displayName:Name name:name type:string * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[3].second displayName:Second name:second type:UnityTexEnv * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[3].second.m_Texture displayName:Texture name:m_Texture type:PPtr<Texture> * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[3].second.m_Scale displayName:Scale name:m_Scale type:Vector2 * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[3].second.m_Scale.x displayName:X name:x type:float * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[3].second.m_Scale.y displayName:Y name:y type:float * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[3].second.m_Offset displayName:Offset name:m_Offset type:Vector2 * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[3].second.m_Offset.x displayName:X name:x type:float * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[3].second.m_Offset.y displayName:Y name:y type:float * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[4] displayName:Element 4 name:data type:pair * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[4].first displayName:First name:first type:FastPropertyName * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[4].first.name displayName:Name name:name type:string * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[4].second displayName:Second name:second type:UnityTexEnv * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[4].second.m_Texture displayName:Texture name:m_Texture type:PPtr<Texture> * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[4].second.m_Scale displayName:Scale name:m_Scale type:Vector2 * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[4].second.m_Scale.x displayName:X name:x type:float * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[4].second.m_Scale.y displayName:Y name:y type:float * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[4].second.m_Offset displayName:Offset name:m_Offset type:Vector2 * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[4].second.m_Offset.x displayName:X name:x type:float * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[4].second.m_Offset.y displayName:Y name:y type:float * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[5] displayName:Element 5 name:data type:pair * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[5].first displayName:First name:first type:FastPropertyName * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[5].first.name displayName:Name name:name type:string * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[5].second displayName:Second name:second type:UnityTexEnv * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[5].second.m_Texture displayName:Texture name:m_Texture type:PPtr<Texture> * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[5].second.m_Scale displayName:Scale name:m_Scale type:Vector2 * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[5].second.m_Scale.x displayName:X name:x type:float * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[5].second.m_Scale.y displayName:Y name:y type:float * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[5].second.m_Offset displayName:Offset name:m_Offset type:Vector2 * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[5].second.m_Offset.x displayName:X name:x type:float * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[5].second.m_Offset.y displayName:Y name:y type:float * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[6] displayName:Element 6 name:data type:pair * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[6].first displayName:First name:first type:FastPropertyName * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[6].first.name displayName:Name name:name type:string * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[6].second displayName:Second name:second type:UnityTexEnv * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[6].second.m_Texture displayName:Texture name:m_Texture type:PPtr<Texture> * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[6].second.m_Scale displayName:Scale name:m_Scale type:Vector2 * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[6].second.m_Scale.x displayName:X name:x type:float * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[6].second.m_Scale.y displayName:Y name:y type:float * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[6].second.m_Offset displayName:Offset name:m_Offset type:Vector2 * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[6].second.m_Offset.x displayName:X name:x type:float * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[6].second.m_Offset.y displayName:Y name:y type:float * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[7] displayName:Element 7 name:data type:pair * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[7].first displayName:First name:first type:FastPropertyName * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[7].first.name displayName:Name name:name type:string * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[7].second displayName:Second name:second type:UnityTexEnv * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[7].second.m_Texture displayName:Texture name:m_Texture type:PPtr<Texture> * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[7].second.m_Scale displayName:Scale name:m_Scale type:Vector2 * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[7].second.m_Scale.x displayName:X name:x type:float * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[7].second.m_Scale.y displayName:Y name:y type:float * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[7].second.m_Offset displayName:Offset name:m_Offset type:Vector2 * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[7].second.m_Offset.x displayName:X name:x type:float * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[7].second.m_Offset.y displayName:Y name:y type:float * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[8] displayName:Element 8 name:data type:pair * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[8].first displayName:First name:first type:FastPropertyName * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[8].first.name displayName:Name name:name type:string * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[8].second displayName:Second name:second type:UnityTexEnv * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[8].second.m_Texture displayName:Texture name:m_Texture type:PPtr<Texture> * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[8].second.m_Scale displayName:Scale name:m_Scale type:Vector2 * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[8].second.m_Scale.x displayName:X name:x type:float * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[8].second.m_Scale.y displayName:Y name:y type:float * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[8].second.m_Offset displayName:Offset name:m_Offset type:Vector2 * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[8].second.m_Offset.x displayName:X name:x type:float * ~ itr:m_SavedProperties.m_TexEnvs.Array.data[8].second.m_Offset.y displayName:Y name:y type:float * ~ itr:m_SavedProperties.m_Floats displayName:Floats name:m_Floats type:map * ~ itr:m_SavedProperties.m_Floats.Array.size displayName:Size name:size type:ArraySize * ~ itr:m_SavedProperties.m_Floats.Array.data[0] displayName:Element 0 name:data type:pair * ~ itr:m_SavedProperties.m_Floats.Array.data[0].first displayName:First name:first type:FastPropertyName * ~ itr:m_SavedProperties.m_Floats.Array.data[0].first.name displayName:Name name:name type:string * ~ itr:m_SavedProperties.m_Floats.Array.data[0].second displayName:Second name:second type:float * ~ itr:m_SavedProperties.m_Floats.Array.data[1] displayName:Element 1 name:data type:pair * ~ itr:m_SavedProperties.m_Floats.Array.data[1].first displayName:First name:first type:FastPropertyName * ~ itr:m_SavedProperties.m_Floats.Array.data[1].first.name displayName:Name name:name type:string * ~ itr:m_SavedProperties.m_Floats.Array.data[1].second displayName:Second name:second type:float * ~ itr:m_SavedProperties.m_Floats.Array.data[2] displayName:Element 2 name:data type:pair * ~ itr:m_SavedProperties.m_Floats.Array.data[2].first displayName:First name:first type:FastPropertyName * ~ itr:m_SavedProperties.m_Floats.Array.data[2].first.name displayName:Name name:name type:string * ~ itr:m_SavedProperties.m_Floats.Array.data[2].second displayName:Second name:second type:float * ~ itr:m_SavedProperties.m_Floats.Array.data[3] displayName:Element 3 name:data type:pair * ~ itr:m_SavedProperties.m_Floats.Array.data[3].first displayName:First name:first type:FastPropertyName * ~ itr:m_SavedProperties.m_Floats.Array.data[3].first.name displayName:Name name:name type:string * ~ itr:m_SavedProperties.m_Floats.Array.data[3].second displayName:Second name:second type:float * ~ itr:m_SavedProperties.m_Floats.Array.data[4] displayName:Element 4 name:data type:pair * ~ itr:m_SavedProperties.m_Floats.Array.data[4].first displayName:First name:first type:FastPropertyName * ~ itr:m_SavedProperties.m_Floats.Array.data[4].first.name displayName:Name name:name type:string * ~ itr:m_SavedProperties.m_Floats.Array.data[4].second displayName:Second name:second type:float * ~ itr:m_SavedProperties.m_Floats.Array.data[5] displayName:Element 5 name:data type:pair * ~ itr:m_SavedProperties.m_Floats.Array.data[5].first displayName:First name:first type:FastPropertyName * ~ itr:m_SavedProperties.m_Floats.Array.data[5].first.name displayName:Name name:name type:string * ~ itr:m_SavedProperties.m_Floats.Array.data[5].second displayName:Second name:second type:float * ~ itr:m_SavedProperties.m_Floats.Array.data[6] displayName:Element 6 name:data type:pair * ~ itr:m_SavedProperties.m_Floats.Array.data[6].first displayName:First name:first type:FastPropertyName * ~ itr:m_SavedProperties.m_Floats.Array.data[6].first.name displayName:Name name:name type:string * ~ itr:m_SavedProperties.m_Floats.Array.data[6].second displayName:Second name:second type:float * ~ itr:m_SavedProperties.m_Floats.Array.data[7] displayName:Element 7 name:data type:pair * ~ itr:m_SavedProperties.m_Floats.Array.data[7].first displayName:First name:first type:FastPropertyName * ~ itr:m_SavedProperties.m_Floats.Array.data[7].first.name displayName:Name name:name type:string * ~ itr:m_SavedProperties.m_Floats.Array.data[7].second displayName:Second name:second type:float * ~ itr:m_SavedProperties.m_Floats.Array.data[8] displayName:Element 8 name:data type:pair * ~ itr:m_SavedProperties.m_Floats.Array.data[8].first displayName:First name:first type:FastPropertyName * ~ itr:m_SavedProperties.m_Floats.Array.data[8].first.name displayName:Name name:name type:string * ~ itr:m_SavedProperties.m_Floats.Array.data[8].second displayName:Second name:second type:float * ~ itr:m_SavedProperties.m_Floats.Array.data[9] displayName:Element 9 name:data type:pair * ~ itr:m_SavedProperties.m_Floats.Array.data[9].first displayName:First name:first type:FastPropertyName * ~ itr:m_SavedProperties.m_Floats.Array.data[9].first.name displayName:Name name:name type:string * ~ itr:m_SavedProperties.m_Floats.Array.data[9].second displayName:Second name:second type:float * ~ itr:m_SavedProperties.m_Floats.Array.data[10] displayName:Element 10 name:data type:pair * ~ itr:m_SavedProperties.m_Floats.Array.data[10].first displayName:First name:first type:FastPropertyName * ~ itr:m_SavedProperties.m_Floats.Array.data[10].first.name displayName:Name name:name type:string * ~ itr:m_SavedProperties.m_Floats.Array.data[10].second displayName:Second name:second type:float * ~ itr:m_SavedProperties.m_Floats.Array.data[11] displayName:Element 11 name:data type:pair * ~ itr:m_SavedProperties.m_Floats.Array.data[11].first displayName:First name:first type:FastPropertyName * ~ itr:m_SavedProperties.m_Floats.Array.data[11].first.name displayName:Name name:name type:string * ~ itr:m_SavedProperties.m_Floats.Array.data[11].second displayName:Second name:second type:float * ~ itr:m_SavedProperties.m_Colors displayName:Colors name:m_Colors type:map * ~ itr:m_SavedProperties.m_Colors.Array.size displayName:Size name:size type:ArraySize * ~ itr:m_SavedProperties.m_Colors.Array.data[0] displayName:Element 0 name:data type:pair * ~ itr:m_SavedProperties.m_Colors.Array.data[0].first displayName:First name:first type:FastPropertyName * ~ itr:m_SavedProperties.m_Colors.Array.data[0].first.name displayName:Name name:name type:string * ~ itr:m_SavedProperties.m_Colors.Array.data[0].second displayName:Second name:second type:Color * ~ itr:m_SavedProperties.m_Colors.Array.data[1] displayName:Element 1 name:data type:pair * ~ itr:m_SavedProperties.m_Colors.Array.data[1].first displayName:First name:first type:FastPropertyName * ~ itr:m_SavedProperties.m_Colors.Array.data[1].first.name displayName:Name name:name type:string * ~ itr:m_SavedProperties.m_Colors.Array.data[1].second displayName:Second name:second type:Color * */ // もしサンプルとの差があれば、この素材には変更があったものとして、関連するPrefabの作成時にprefabのキャッシュを消すとかする。 // if (!same) { // effector.ForceOnPreprocessTexture(texImporter); // importSetOveredAssetsAndUpdatedFlagDict[inputSource] = true; // } // とりあえず決め打ちで、変化があったものとしてみなす。デバッグ中。 Debug.LogError("modifierは、現状「通過した素材の設定が変更されてるかどうか把握できない」ので、常に新規扱いになっている。そのため、このファイルと、このファイルを使ったpredab生成が常に新作になり、キャッシュが効かないようになっている。"); importSetOveredAssetsAndUpdatedFlagDict[inputSource] = true; break; } default: { throw new Exception("unhandled modifier type:" + importerTypeStr); } } } } } /* * 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.MODIFIER_SAMPLING_PLACE, nodeId); var sampleAssetPath = string.Empty; ValidateModifierSample(samplingDirectoryPath, (string noSampleFolder) => { Debug.LogWarning("modifierSetting:" + noSampleFolder); }, (string noSampleFile) => { throw new Exception("modifierSetting error:" + noSampleFile); }, (string samplePath) => { Debug.Log("using modifier setting:" + samplePath); sampleAssetPath = samplePath; }, (string tooManysample) => { throw new Exception("modifierSetting 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("modifierSetting 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 modifierSetting to file. */ { var samplingAssetImporter = AssetImporter.GetAtPath(sampleAssetPath); var effector = new InternalSamplingImportEffector(samplingAssetImporter); { foreach (var inputSource in inputSources) { var importer = AssetImporter.GetAtPath(inputSource.importedPath); /* compare type of import setting effector. */ var importerTypeStr = importer.GetType().ToString(); if (importerTypeStr != samplingAssetImporter.GetType().ToString()) { // mismatched target will be ignored. but already imported. importSetOveredAssetsAndUpdatedFlagDict[inputSource] = false; continue; } importSetOveredAssetsAndUpdatedFlagDict[inputSource] = false; /* kind of importer is matched. check setting then apply setting or no changed. */ switch (importerTypeStr) { case "UnityEditor.AssetImporter": {// materials and others... assets which are generated in Unity. // Modifier is under development. do nothing in this node yet. // importSetOveredAssetsAndUpdatedFlagDict[inputSource] = true; break; } default: { throw new Exception("unhandled modifier type:" + importerTypeStr); } } } } } /* 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); }