public void Setup(string nodeName, string nodeId, string unused_connectionIdToNextNode, Dictionary <string, List <InternalAssetData> > groupedSources, List <string> alreadyCached, Action <string, string, Dictionary <string, List <InternalAssetData> >, List <string> > Output) { try { ValidateBundleNameTemplate( bundleNameTemplate, () => { throw new NodeException(nodeName + ":Bundle Name Template is empty.", nodeId); } ); } catch (NodeException e) { AssetBundleGraph.AddNodeException(e); return; } var recommendedBundleOutputDir = FileController.PathCombine(AssetBundleGraphSettings.BUNDLIZER_CACHE_PLACE, nodeId, GraphStackController.GetCurrentPlatformPackageFolder()); var outputDict = new Dictionary <string, List <InternalAssetData> >(); foreach (var groupKey in groupedSources.Keys) { var inputSources = groupedSources[groupKey]; var reservedBundlePath = BundlizeAssets(nodeName, groupKey, inputSources, recommendedBundleOutputDir, false); if (string.IsNullOrEmpty(reservedBundlePath)) { continue; } var outputSources = new List <InternalAssetData>(); var newAssetData = InternalAssetData.InternalAssetDataGeneratedByBundlizer(reservedBundlePath); outputSources.Add(newAssetData); outputDict[groupKey] = outputSources; } if (assetsOutputConnectionId != AssetBundleGraphSettings.BUNDLIZER_FAKE_CONNECTION_ID) { Output(nodeId, assetsOutputConnectionId, outputDict, new List <string>()); } /* * generate additional output: * output bundle resources for next node, for generate another AssetBundles with dependency. */ if (outputResource) { if (resourcesOutputConnectionId != AssetBundleGraphSettings.BUNDLIZER_FAKE_CONNECTION_ID) { Output(nodeId, resourcesOutputConnectionId, groupedSources, new List <string>()); } } }
public void Setup(string nodeName, string nodeId, string unused_connectionIdToNextNode, Dictionary <string, List <InternalAssetData> > groupedSources, List <string> alreadyCached, Action <string, string, Dictionary <string, List <InternalAssetData> >, List <string> > Output) { // overlapping test. try { var overlappingCheckList = new List <string>(); for (var i = 0; i < containsKeywords.Count; i++) { var keywordAndKeytypeCombind = containsKeywords[i] + containsKeytypes[i]; if (overlappingCheckList.Contains(keywordAndKeytypeCombind)) { throw new NodeException(String.Format("Duplicated filter condition found for [Keyword:{0} Type:{1}]", containsKeywords[i], containsKeytypes[i]), nodeId); } overlappingCheckList.Add(keywordAndKeytypeCombind); } } catch (NodeException e) { AssetBundleGraph.AddNodeException(e); return; } foreach (var groupKey in groupedSources.Keys) { var outputDict = new Dictionary <string, List <InternalAssetData> >(); var inputSources = groupedSources[groupKey]; Action <string, List <string> > _PreOutput = (string connectionId, List <string> outputSources) => { var outputs = new List <InternalAssetData>(); foreach (var outputSource in outputSources) { foreach (var inputSource in inputSources) { if (outputSource == inputSource.GetAbsolutePathOrImportedPath()) { outputs.Add(inputSource); } } } outputDict[groupKey] = outputs; Output(nodeId, connectionId, outputDict, new List <string>()); }; try { Filter(inputSources, _PreOutput); } catch (Exception e) { Debug.LogError(nodeName + " Error:" + e); } } }
private void GroupingOutput(string nodeName, string nodeId, string connectionIdToNextNode, Dictionary <string, List <InternalAssetData> > groupedSources, Action <string, string, Dictionary <string, List <InternalAssetData> >, List <string> > Output) { try { ValidateGroupingKeyword( groupingKeyword, () => { throw new NodeException("Grouping Keyword can not be empty.", nodeId); }, () => { throw new NodeException(String.Format("Grouping Keyword must contain {0} for numbering: currently {1}", AssetBundleGraphSettings.KEYWORD_WILDCARD, groupingKeyword), nodeId); } ); } catch (NodeException e) { AssetBundleGraph.AddNodeException(e); return; } var outputDict = new Dictionary <string, List <InternalAssetData> >(); var mergedGroupedSources = new List <InternalAssetData>(); foreach (var groupKey in groupedSources.Keys) { mergedGroupedSources.AddRange(groupedSources[groupKey]); } foreach (var source in mergedGroupedSources) { var targetPath = source.GetAbsolutePathOrImportedPath(); var groupingKeywordPrefix = groupingKeyword.Split(AssetBundleGraphSettings.KEYWORD_WILDCARD)[0]; var groupingKeywordPostfix = groupingKeyword.Split(AssetBundleGraphSettings.KEYWORD_WILDCARD)[1]; var regex = new Regex(groupingKeywordPrefix + "(.*?)" + groupingKeywordPostfix); var match = regex.Match(targetPath); if (match.Success) { var newGroupingKey = match.Groups[1].Value; if (!outputDict.ContainsKey(newGroupingKey)) { outputDict[newGroupingKey] = new List <InternalAssetData>(); } outputDict[newGroupingKey].Add(source); } } Output(nodeId, connectionIdToNextNode, outputDict, new List <string>()); }
public void Setup(string nodeName, string nodeId, string connectionIdToNextNode, Dictionary <string, List <InternalAssetData> > groupedSources, List <string> alreadyCached, Action <string, string, Dictionary <string, List <InternalAssetData> >, List <string> > Output) { try { ValidateExportPath( exportFilePath, exportFilePath, () => { throw new NodeException(nodeName + ":Export Path is empty.", nodeId); }, () => { throw new NodeException(nodeName + ":Directory set to Export Path does not exist. Path:" + exportFilePath, nodeId); } ); } catch (NodeException e) { AssetBundleGraph.AddNodeException(e); return; } Export(nodeName, nodeId, connectionIdToNextNode, groupedSources, Output, false); }
private void UpdateNodeName(Node node) { var newName = EditorGUILayout.TextField("Node Name", node.name); if (Node.allNodeNames != null) { var overlapping = Node.allNodeNames.GroupBy(x => x) .Where(group => group.Count() > 1) .Select(group => group.Key); if (overlapping.Any() && overlapping.Contains(newName)) { EditorGUILayout.HelpBox("This node name already exist. Please put other name:" + newName, MessageType.Error); AssetBundleGraph.AddNodeException(new NodeException("Node name " + newName + " already exist.", node.nodeId)); } } if (newName != node.name) { node.BeforeSave(); node.name = newName; node.UpdateNodeRect(); node.Save(); } }
private void DoInspectorModifierGUI(Node node) { EditorGUILayout.HelpBox("Modifier: Force apply asset settings to given assets.", MessageType.Info); UpdateNodeName(node); GUILayout.Space(10f); var currentModifierTargetType = IntegratedGUIModifier.ModifierOperationTargetTypeName(node.nodeId); using (new EditorGUILayout.VerticalScope(GUI.skin.box)) { var isOperationDataExist = false; IntegratedGUIModifier.ValidateModifiyOperationData( node.nodeId, node.currentPlatform, () => { GUILayout.Label("No modifier data found, please Reload first."); }, () => { isOperationDataExist = true; } ); if (!isOperationDataExist) { return; } using (new EditorGUILayout.HorizontalScope()) { GUILayout.Label("Target Type:"); GUILayout.Label(currentModifierTargetType); } /* * reset whole platform's data for this modifier. */ if (GUILayout.Button("Reset Modifier")) { var modifierFolderPath = FileController.PathCombine(AssetBundleGraphSettings.MODIFIER_OPERATOR_DATAS_PLACE, node.nodeId); FileController.RemakeDirectory(modifierFolderPath); node.Save(); modifierOperatorInstance = null; return; } } var currentPlatform = node.currentPlatform; node.currentPlatform = UpdateCurrentPlatform(node.currentPlatform); /* * if platform tab is changed, renew modifierOperatorInstance for that tab. */ if (currentPlatform != node.currentPlatform) { modifierOperatorInstance = null; } /* * reload modifierOperator instance from saved modifierOperator data. */ if (modifierOperatorInstance == null) { var modifierOperatorDataPath = IntegratedGUIModifier.ModifierDataPathForeachPlatform(node.nodeId, node.currentPlatform); // choose default modifierOperatorData if platform specified file is not exist. if (!File.Exists(modifierOperatorDataPath)) { modifierOperatorDataPath = IntegratedGUIModifier.ModifierDataPathForDefaultPlatform(node.nodeId); } var loadedModifierOperatorDataStr = string.Empty; using (var sr = new StreamReader(modifierOperatorDataPath)) { loadedModifierOperatorDataStr = sr.ReadToEnd(); } var modifierOperatorType = TypeBinder.SupportedModifierOperatorDefinition[currentModifierTargetType]; /* * create instance from saved modifierOperator data. */ modifierOperatorInstance = typeof(NodeEditor) .GetMethod("FromJson") .MakeGenericMethod(modifierOperatorType)// set desired generic type here. .Invoke(this, new object[] { loadedModifierOperatorDataStr }) as ModifierOperators.OperatorBase; } /* * Show ModifierOperator Inspector. */ if (modifierOperatorInstance != null) { Action changed = () => { var data = JsonUtility.ToJson(modifierOperatorInstance); var prettified = AssetBundleGraph.PrettifyJson(data); var modifierOperatorDataPath = IntegratedGUIModifier.ModifierDataPathForeachPlatform(node.nodeId, node.currentPlatform); using (var sw = new StreamWriter(modifierOperatorDataPath)) { sw.Write(prettified); } // reflect change of data. AssetDatabase.Refresh(); modifierOperatorInstance = null; }; GUILayout.Space(10f); modifierOperatorInstance.DrawInspector(changed); } var deleted = UpdateDeleteSetting(node); if (deleted) { // source platform depended data is deleted. reload instance for reloading instance from data. modifierOperatorInstance = null; } }
public void Setup(string nodeName, string nodeId, string connectionIdToNextNode, Dictionary <string, List <InternalAssetData> > unused, List <string> alreadyCached, Action <string, string, Dictionary <string, List <InternalAssetData> >, List <string> > Output) { try { ValidateLoadPath( loadFilePath, loadFilePath, () => { //throw new NodeException(nodeName + ": Load Path is empty.", nodeId); }, () => { throw new NodeException(nodeName + ": Directory not found: " + loadFilePath, nodeId); } ); } catch (NodeException e) { AssetBundleGraph.AddNodeException(e); return; } // SOMEWHERE_FULLPATH/PROJECT_FOLDER/Assets/ var assetsFolderPath = Application.dataPath + AssetBundleGraphSettings.UNITY_FOLDER_SEPARATOR; var outputSource = new List <InternalAssetData>(); var targetFilePaths = FileController.FilePathsInFolder(loadFilePath); try { foreach (var targetFilePath in targetFilePaths) { if (targetFilePath.Contains(AssetBundleGraphSettings.ASSETBUNDLEGRAPH_PATH)) { continue; } // already contained into Assets/ folder. // imported path is Assets/SOMEWHERE_FILE_EXISTS. if (targetFilePath.StartsWith(assetsFolderPath)) { var importedPath = targetFilePath.Replace(assetsFolderPath, AssetBundleGraphSettings.ASSETS_PATH); var assetType = AssetBundleGraphInternalFunctions.GetAssetType(importedPath); if (assetType == typeof(object)) { continue; } outputSource.Add( InternalAssetData.InternalImportedAssetDataByLoader( targetFilePath, loadFilePath, importedPath, AssetDatabase.AssetPathToGUID(importedPath), assetType ) ); continue; } throw new NodeException(nodeName + ": Invalid Load Path. Path must start with Assets/", nodeId); } } catch (NodeException e) { AssetBundleGraph.AddNodeException(e); return; } catch (Exception e) { Debug.LogError(nodeName + " Error:" + e); } var outputDir = new Dictionary <string, List <InternalAssetData> > { { "0", outputSource } }; Output(nodeId, connectionIdToNextNode, outputDir, new List <string>()); }
public void Setup(string nodeName, string nodeId, string connectionIdToNextNode, Dictionary <string, List <InternalAssetData> > groupedSources, List <string> alreadyCached, Action <string, string, Dictionary <string, List <InternalAssetData> >, List <string> > Output) { if (groupedSources.Keys.Count == 0) { return; } // Modifier merges multiple incoming groups into one. if (1 < groupedSources.Keys.Count) { Debug.LogWarning(nodeName + " Modifier merges incoming group into \"" + groupedSources.Keys.ToList()[0]); } var groupMergeKey = groupedSources.Keys.ToList()[0]; // merge all assets into single list. var inputSources = new List <InternalAssetData>(); foreach (var groupKey in groupedSources.Keys) { inputSources.AddRange(groupedSources[groupKey]); } if (!inputSources.Any()) { return; } // initialize as object. var modifierType = string.Empty; var first = true; foreach (var inputSource in inputSources) { var modifyTargetAssetPath = inputSource.importedPath; var assumedType = TypeBinder.AssumeTypeOfAsset(modifyTargetAssetPath); if (assumedType == null || assumedType == typeof(object)) { continue; } if (first) { first = false; modifierType = assumedType.ToString(); continue; } if (modifierType != assumedType.ToString()) { throw new NodeException("multiple Asset Type detected. consider reduce Asset Type number to only 1 by Filter. detected Asset Types is:" + modifierType + " , and " + assumedType.ToString(), nodeId); } } // modifierType is fixed. check support. if (!TypeBinder.SupportedModifierOperatorDefinition.ContainsKey(modifierType)) { throw new NodeException("current incoming Asset Type:" + modifierType + " is unsupported.", nodeId); } // generate modifierOperatorData if data is not exist yet. { var modifierOperatorDataFolderPath = AssetBundleGraphSettings.MODIFIER_OPERATOR_DATAS_PLACE; if (!Directory.Exists(modifierOperatorDataFolderPath)) { Directory.CreateDirectory(modifierOperatorDataFolderPath); } var opDataFolderPath = FileController.PathCombine(modifierOperatorDataFolderPath, nodeId); if (!Directory.Exists(opDataFolderPath)) { Directory.CreateDirectory(opDataFolderPath); } // ready default platform path. var modifierOperatorDataPathForDefaultPlatform = FileController.PathCombine(opDataFolderPath, ModifierOperatiorDataName(AssetBundleGraphSettings.PLATFORM_DEFAULT_NAME)); /* * create default platform ModifierOperatorData if not exist. * default ModifierOperatorData is the target platform for every platform by default. */ if (!File.Exists(modifierOperatorDataPathForDefaultPlatform)) { var operatorType = TypeBinder.SupportedModifierOperatorDefinition[modifierType]; var operatorInstance = Activator.CreateInstance(operatorType) as ModifierOperators.OperatorBase; var defaultRenderTextureOp = operatorInstance.DefaultSetting(); /* * generated json data is typed as supported ModifierOperation type. */ var jsonData = JsonUtility.ToJson(defaultRenderTextureOp); var prettified = AssetBundleGraph.PrettifyJson(jsonData); using (var sw = new StreamWriter(modifierOperatorDataPathForDefaultPlatform)) { sw.WriteLine(prettified); } } } // validate saved data. ValidateModifiyOperationData( nodeId, currentPlatformStr, () => { throw new NodeException("No ModifierOperatorData found. please Setup first.", nodeId); }, () => { /*do nothing.*/ } ); var outputSources = new List <InternalAssetData>(); /* * all assets types are same and do nothing to assets in setup. */ foreach (var inputSource in inputSources) { var modifyTargetAssetPath = inputSource.importedPath; var newData = InternalAssetData.InternalAssetDataByImporterOrModifier( inputSource.traceId, inputSource.absoluteSourcePath, inputSource.sourceBasePath, inputSource.fileNameAndExtension, inputSource.pathUnderSourceBase, inputSource.importedPath, null, inputSource.assetType ); outputSources.Add(newData); } var outputDict = new Dictionary <string, List <InternalAssetData> >(); outputDict[groupMergeKey] = outputSources; Output(nodeId, connectionIdToNextNode, outputDict, new List <string>()); }