private void DoInspectorGroupingGUI(NodeGUI node) { if (node.groupingKeyword == null) { return; } EditorGUILayout.HelpBox("Grouping: Create group of assets.", MessageType.Info); UpdateNodeName(node); GUILayout.Space(10f); node.currentPlatform = UpdateCurrentPlatform(node.currentPlatform); using (new EditorGUILayout.VerticalScope(GUI.skin.box)) { var newGroupingKeyword = EditorGUILayout.TextField( "Grouping Keyword", SystemDataUtility.GetPlatformValue( node.groupingKeyword.ReadonlyDict(), node.currentPlatform ).ToString() ); EditorGUILayout.HelpBox("Grouping Keyword requires \"*\" in itself. It assumes there is a pattern such as \"ID_0\" in incoming paths when configured as \"ID_*\" ", MessageType.Info); IntegratedGUIGrouping.ValidateGroupingKeyword( newGroupingKeyword, () => { // EditorGUILayout.HelpBox("groupingKeyword is empty.", MessageType.Error); }, () => { // EditorGUILayout.HelpBox("grouping keyword does not contain " + AssetBundleGraphSettings.KEYWORD_WILDCARD + " groupingKeyword:" + newGroupingKeyword, MessageType.Error); } ); if (newGroupingKeyword != SystemDataUtility.GetPlatformValue( node.groupingKeyword.ReadonlyDict(), node.currentPlatform ).ToString() ) { node.BeforeSave(); node.groupingKeyword.Add(SystemDataUtility.CreateKeyNameFromString(node.currentPlatform), newGroupingKeyword); node.Save(); } } UpdateDeleteSetting(node); }
private void DoInspectorLoaderGUI(NodeGUI node) { if (node.Data.LoaderLoadPath == null) { return; } EditorGUILayout.HelpBox("Loader: Load assets in given directory path.", MessageType.Info); UpdateNodeName(node); GUILayout.Space(10f); //Show target configuration tab DrawPlatformSelector(node); using (new EditorGUILayout.VerticalScope(GUI.skin.box)) { var disabledScope = DrawOverrideTargetToggle(node, node.Data.LoaderLoadPath.ContainsValueOf(currentEditingGroup), (bool b) => { using (new RecordUndoScope("Remove Target Load Path Settings", node, true)) { if (b) { node.Data.LoaderLoadPath[currentEditingGroup] = node.Data.LoaderLoadPath.DefaultValue; } else { node.Data.LoaderLoadPath.Remove(currentEditingGroup); } } }); using (disabledScope) { EditorGUILayout.LabelField("Load Path:"); var newLoadPath = EditorGUILayout.TextField( SystemDataUtility.GetProjectName() + AssetBundleGraphSettings.ASSETS_PATH, node.Data.LoaderLoadPath[currentEditingGroup] ); if (newLoadPath != node.Data.LoaderLoadPath[currentEditingGroup]) { using (new RecordUndoScope("Load Path Changed", node, true)){ node.Data.LoaderLoadPath[currentEditingGroup] = newLoadPath; } } } } }
private bool UpdateDeleteSetting(NodeGUI currentNode) { var currentNodePlatformPackageKey = SystemDataUtility.CreateKeyNameFromString(currentNode.currentPlatform); if (currentNodePlatformPackageKey == AssetBundleGraphSettings.PLATFORM_DEFAULT_NAME) { return(false); } var deleted = false; using (new EditorGUILayout.HorizontalScope()) { GUILayout.FlexibleSpace(); if (GUILayout.Button("Use Default Setting", GUILayout.Width(150))) { currentNode.BeforeSave(); currentNode.DeleteCurrentPackagePlatformKey(currentNodePlatformPackageKey); GUI.FocusControl(string.Empty); currentNode.Save(); deleted = true; } } return(deleted); }
private void DoInspectorBundlizerGUI(NodeGUI node) { if (node.bundleNameTemplate == null) { return; } EditorGUILayout.HelpBox("Bundlizer: Create asset bundle settings with given group of assets.", MessageType.Info); UpdateNodeName(node); GUILayout.Space(10f); node.currentPlatform = UpdateCurrentPlatform(node.currentPlatform); using (new EditorGUILayout.VerticalScope(GUI.skin.box)) { var bundleNameTemplate = EditorGUILayout.TextField( "Bundle Name Template", SystemDataUtility.GetPlatformValue( node.bundleNameTemplate.ReadonlyDict(), node.currentPlatform ).ToString() ).ToLower(); IntegratedGUIBundlizer.ValidateBundleNameTemplate( bundleNameTemplate, () => { // EditorGUILayout.HelpBox("No Bundle Name Template set.", MessageType.Error); } ); if (bundleNameTemplate != SystemDataUtility.GetPlatformValue( node.bundleNameTemplate.ReadonlyDict(), node.currentPlatform ).ToString() ) { node.BeforeSave(); node.bundleNameTemplate.Add(SystemDataUtility.CreateKeyNameFromString(node.currentPlatform), bundleNameTemplate); node.Save(); } GUILayout.Label("Variants:"); for (int i = 0; i < node.variants.Keys.Count; ++i) { var inputConnectionId = node.variants.Keys[i]; using (new GUILayout.HorizontalScope()) { if (GUILayout.Button("-", GUILayout.Width(30))) { node.BeforeSave(); node.variants.Remove(inputConnectionId); node.DeleteInputPoint(inputConnectionId); } else { var variantName = node.variants.Values[i]; GUIStyle s = new GUIStyle((GUIStyle)"TextFieldDropDownText"); Action makeStyleBold = () => { s.fontStyle = FontStyle.Bold; s.fontSize = 12; }; IntegratedGUIBundlizer.ValidateVariantName(variantName, node.variants.Values, makeStyleBold, makeStyleBold, makeStyleBold); variantName = EditorGUILayout.TextField(variantName, s); if (variantName != node.variants.Values[i]) { node.BeforeSave(); node.variants.Values[i] = variantName; node.RenameInputPoint(inputConnectionId, variantName); } } } } if (GUILayout.Button("+")) { node.BeforeSave(); var newid = Guid.NewGuid().ToString(); node.variants.Add(newid, AssetBundleGraphSettings.BUNDLIZER_VARIANTNAME_DEFAULT); node.AddInputPoint(newid, AssetBundleGraphSettings.BUNDLIZER_VARIANTNAME_DEFAULT); } } UpdateDeleteSetting(node); }
private void DoInspectorLoaderGUI(NodeGUI node) { if (node.loadPath == null) { return; } EditorGUILayout.HelpBox("Loader: Load assets in given directory path.", MessageType.Info); UpdateNodeName(node); GUILayout.Space(10f); /* * platform & package */ if (packageEditMode) { EditorGUI.BeginDisabledGroup(true); } // update platform & package. node.currentPlatform = UpdateCurrentPlatform(node.currentPlatform); using (new EditorGUILayout.VerticalScope(GUI.skin.box)) { EditorGUILayout.LabelField("Load Path:"); var newLoadPath = EditorGUILayout.TextField( SystemDataUtility.GetProjectName() + AssetBundleGraphSettings.ASSETS_PATH, SystemDataUtility.GetPlatformValue( node.loadPath.ReadonlyDict(), node.currentPlatform ).ToString() ); var loaderNodePath = FileUtility.GetPathWithAssetsPath(newLoadPath); IntegratedGUILoader.ValidateLoadPath( newLoadPath, loaderNodePath, () => { //EditorGUILayout.HelpBox("load path is empty.", MessageType.Error); }, () => { //EditorGUILayout.HelpBox("Directory not found:" + loaderNodePath, MessageType.Error); } ); if (newLoadPath != SystemDataUtility.GetPlatformValue( node.loadPath.ReadonlyDict(), node.currentPlatform ).ToString() ) { node.BeforeSave(); node.loadPath.Add(SystemDataUtility.CreateKeyNameFromString(node.currentPlatform), newLoadPath); node.Save(); } } if (packageEditMode) { EditorGUI.EndDisabledGroup(); } UpdateDeleteSetting(node); }
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 invalids = new List <string>(); foreach (var sources in groupedSources.Values) { foreach (var source in sources) { if (string.IsNullOrEmpty(source.importFrom)) { invalids.Add(source.absoluteAssetPath); } } } if (invalids.Any()) { throw new NodeException(string.Join(", ", invalids.ToArray()) + " are not imported yet. These assets need to be imported before prefabricated.", nodeId); } var recommendedPrefabOutputDirectoryPath = FileUtility.PathCombine(AssetBundleGraphSettings.PREFABRICATOR_CACHE_PLACE, nodeId, SystemDataUtility.GetCurrentPlatformKey()); var outputDict = new Dictionary <string, List <Asset> >(); var cachedOrGenerated = new List <string>(); foreach (var groupKey in groupedSources.Keys) { var inputSources = groupedSources[groupKey]; var recommendedPrefabPath = FileUtility.PathCombine(recommendedPrefabOutputDirectoryPath, groupKey); if (!recommendedPrefabPath.EndsWith(AssetBundleGraphSettings.UNITY_FOLDER_SEPARATOR.ToString())) { recommendedPrefabPath = recommendedPrefabPath + AssetBundleGraphSettings.UNITY_FOLDER_SEPARATOR.ToString(); } /* * ready input resource info for execute. not contains cache in this node. */ var assets = new List <DepreacatedAssetInfo>(); foreach (var assetData in inputSources) { var assetName = assetData.fileNameAndExtension; var assetType = assetData.assetType; var assetPath = assetData.importFrom; var assetDatabaseId = assetData.assetDatabaseId; assets.Add(new DepreacatedAssetInfo(assetName, assetType, assetPath, assetDatabaseId)); } // collect generated prefab path. var generated = new List <string>(); var outputSources = new List <Asset>(); /* * Prefabricate(GameObject baseObject, string prefabName, bool forceGenerate) method. */ Func <GameObject, string, bool, string> Prefabricate = (GameObject baseObject, string prefabName, bool forceGenerate) => { var newPrefabOutputPath = Path.Combine(recommendedPrefabPath, prefabName); if (forceGenerate || !SystemDataUtility.IsAllAssetsCachedAndUpdated(inputSources, alreadyCached, newPrefabOutputPath)) { // not cached, create new. UnityEngine.Object prefabFile = PrefabUtility.CreateEmptyPrefab(newPrefabOutputPath); // export prefab data. PrefabUtility.ReplacePrefab(baseObject, prefabFile); // save prefab. AssetDatabase.Refresh(ImportAssetOptions.ImportRecursive); AssetDatabase.SaveAssets(); generated.Add(newPrefabOutputPath); cachedOrGenerated.Add(newPrefabOutputPath); Debug.Log(nodeName + " created new prefab: " + newPrefabOutputPath); } else { // cached. usedCache.Add(newPrefabOutputPath); cachedOrGenerated.Add(newPrefabOutputPath); Debug.Log(nodeName + " used cached prefab: " + newPrefabOutputPath); } isPrefabricateFunctionCalled = true; return(newPrefabOutputPath); }; if (!Directory.Exists(recommendedPrefabPath)) { // create recommended directory. Directory.CreateDirectory(recommendedPrefabPath); } /* * execute inheritee's input method. */ try { CreatePrefab(nodeName, nodeId, groupKey, assets, recommendedPrefabPath, Prefabricate); } catch (Exception e) { Debug.LogError(nodeName + " Error:" + e); throw new NodeException(nodeName + " Error:" + e, nodeId); } if (!isPrefabricateFunctionCalled) { Debug.LogWarning(nodeName + ": Prefabricate delegate was not called. Prefab might not be created properly."); } /* * ready assets-output-data from this node to next output. * it contains "cached" or "generated as prefab" or "else" assets. * output all assets. */ var currentAssetsInThisNode = FileUtility.FilePathsInFolder(recommendedPrefabPath); foreach (var generatedCandidateAssetPath in currentAssetsInThisNode) { /* * candidate is new, regenerated prefab. */ if (generated.Contains(generatedCandidateAssetPath)) { var newAsset = Asset.CreateNewAssetWithImportPathAndStatus( generatedCandidateAssetPath, true, false ); outputSources.Add(newAsset); continue; } /* * candidate is not new prefab. */ var cachedPrefabAsset = Asset.CreateNewAssetWithImportPathAndStatus( generatedCandidateAssetPath, false, false ); outputSources.Add(cachedPrefabAsset); } /* * add current resources to next node's resources. */ outputSources.AddRange(inputSources); outputDict[groupKey] = outputSources; } // delete unused cached prefabs. var unusedCachePaths = alreadyCached.Except(cachedOrGenerated).Where(path => !FileUtility.IsMetaFile(path)).ToList(); foreach (var unusedCachePath in unusedCachePaths) { // unbundlize unused prefabricated cached asset. var assetImporter = AssetImporter.GetAtPath(unusedCachePath); assetImporter.assetBundleName = string.Empty; FileUtility.DeleteFileThenDeleteFolderIfEmpty(unusedCachePath); } Output(nodeId, connectionIdToNextNode, outputDict, usedCache); }
public void Setup(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 invalids = new List <string>(); foreach (var sources in groupedSources.Values) { foreach (var source in sources) { if (string.IsNullOrEmpty(source.importFrom)) { invalids.Add(source.absoluteAssetPath); } } } if (invalids.Any()) { throw new NodeException(string.Join(", ", invalids.ToArray()) + " are not imported yet. These assets need to be imported before prefabricated.", nodeId); } var recommendedPrefabOutputDirectoryPath = FileUtility.PathCombine(AssetBundleGraphSettings.PREFABRICATOR_CACHE_PLACE, nodeId, SystemDataUtility.GetCurrentPlatformKey()); var outputDict = new Dictionary <string, List <Asset> >(); foreach (var groupKey in groupedSources.Keys) { var inputSources = groupedSources[groupKey]; var recommendedPrefabPath = FileUtility.PathCombine(recommendedPrefabOutputDirectoryPath, groupKey); if (!recommendedPrefabPath.EndsWith(AssetBundleGraphSettings.UNITY_FOLDER_SEPARATOR.ToString())) { recommendedPrefabPath = recommendedPrefabPath + AssetBundleGraphSettings.UNITY_FOLDER_SEPARATOR.ToString(); } /* * ready input resource info for execute. not contains cache in this node. */ var assets = new List <DepreacatedAssetInfo>(); foreach (var assetData in inputSources) { var assetName = assetData.fileNameAndExtension; var assetType = assetData.assetType; var assetPath = assetData.importFrom; var assetDatabaseId = assetData.assetDatabaseId; assets.Add(new DepreacatedAssetInfo(assetName, assetType, assetPath, assetDatabaseId)); } // collect generated prefab path. var generated = new List <string>(); /* * Prefabricate(string prefabName) method. */ Func <string, string> Prefabricate = (string prefabName) => { var newPrefabOutputPath = Path.Combine(recommendedPrefabPath, prefabName); generated.Add(newPrefabOutputPath); isPrefabricateFunctionCalled = true; return(newPrefabOutputPath); }; ValidateCanCreatePrefab(nodeName, nodeId, groupKey, assets, recommendedPrefabPath, Prefabricate); if (!isPrefabricateFunctionCalled) { Debug.LogWarning(nodeName + ": Prefabricate delegate was not called. Prefab might not be created properly."); } foreach (var generatedPrefabPath in generated) { var newAsset = Asset.CreateNewAssetWithImportPathAndStatus( generatedPrefabPath, true, // absolutely new in setup. false ); if (!outputDict.ContainsKey(groupKey)) { outputDict[groupKey] = new List <Asset>(); } outputDict[groupKey].Add(newAsset); } outputDict[groupKey].AddRange(inputSources); } Output(nodeId, connectionIdToNextNode, outputDict, new List <string>()); }
/** * Perform Run or Setup from parent of given terminal node recursively. */ private static void DoNodeOperation( string nodeId, List <NodeData> allNodes, List <ConnectionData> allConnections, Dictionary <string, Dictionary <string, List <Asset> > > resultDict, Dictionary <string, List <string> > cachedDict, List <string> usedConnectionIds, bool isActualRun, Action <string, float> updateHandler = null ) { var relatedNodes = allNodes.Where(relation => relation.nodeId == nodeId).ToList(); if (!relatedNodes.Any()) { return; } var currentNodeData = relatedNodes[0]; if (currentNodeData.IsAlreadyDone()) { return; } var nodeName = currentNodeData.nodeName; var nodeKind = currentNodeData.nodeKind; /* * Perform prarent node recursively from this node */ foreach (var connectionToParent in currentNodeData.connectionToParents) { var parentNodeId = connectionToParent.fromNodeId; var usedConnectionId = connectionToParent.connectionId; if (usedConnectionIds.Contains(usedConnectionId)) { throw new NodeException("connection loop detected.", parentNodeId); } usedConnectionIds.Add(usedConnectionId); var parentNode = allNodes.Where(node => node.nodeId == parentNodeId).ToList(); if (!parentNode.Any()) { return; } var parentNodeKind = parentNode[0].nodeKind; // check node kind order. SystemDataValidator.ValidateAssertNodeOrder(parentNodeKind, nodeKind); DoNodeOperation(parentNodeId, allNodes, allConnections, resultDict, cachedDict, usedConnectionIds, isActualRun, updateHandler); } /* * Perform node operation for this node */ // connections Ids from this node to child nodes. non-ordered. // actual running order depends on order of Node's OutputPoint order. var nonOrderedConnectionsFromThisNodeToChildNode = allConnections .Where(con => con.fromNodeId == nodeId) .ToList(); var orderedNodeOutputPointIds = allNodes.Where(node => node.nodeId == nodeId).SelectMany(node => node.outputPointIds).ToList(); /* * get connection ids which is orderd by node's outputPoint-order. */ var orderedConnectionIds = new List <string>(nonOrderedConnectionsFromThisNodeToChildNode.Count); foreach (var orderedNodeOutputPointId in orderedNodeOutputPointIds) { foreach (var nonOrderedConnectionFromThisNodeToChildNode in nonOrderedConnectionsFromThisNodeToChildNode) { var nonOrderedConnectionOutputPointId = nonOrderedConnectionFromThisNodeToChildNode.fromNodeOutputPointId; if (orderedNodeOutputPointId == nonOrderedConnectionOutputPointId) { orderedConnectionIds.Add(nonOrderedConnectionFromThisNodeToChildNode.connectionId); continue; } } } /* * FilterNode and BundlizerNode uses specific multiple output connections. * ExportNode does not have output. * but all other nodes has only one output connection and uses first connection. */ var firstConnectionIdFromThisNodeToChildNode = string.Empty; if (orderedConnectionIds.Any()) { firstConnectionIdFromThisNodeToChildNode = orderedConnectionIds[0]; } if (updateHandler != null) { updateHandler(nodeId, 0f); } /* * has next node, run first time. */ var alreadyCachedPaths = new List <string>(); if (cachedDict.ContainsKey(nodeId)) { alreadyCachedPaths.AddRange(cachedDict[nodeId]); } /* * load already exist cache from node. */ alreadyCachedPaths.AddRange(GetCachedDataByNodeKind(nodeKind, nodeId)); var inputParentResults = new Dictionary <string, List <Asset> >(); var receivingConnectionIds = allConnections .Where(con => con.toNodeId == nodeId) .Select(con => con.connectionId) .ToList(); foreach (var connecionId in receivingConnectionIds) { if (!resultDict.ContainsKey(connecionId)) { continue; } var result = resultDict[connecionId]; foreach (var groupKey in result.Keys) { if (!inputParentResults.ContainsKey(groupKey)) { inputParentResults[groupKey] = new List <Asset>(); } inputParentResults[groupKey].AddRange(result[groupKey]); } } /* * the Action passes to NodeOperaitons. * It stores result to resultDict. */ Action <string, string, Dictionary <string, List <Asset> >, List <string> > Output = (string dataSourceNodeId, string targetConnectionId, Dictionary <string, List <Asset> > result, List <string> justCached) => { var targetConnectionIds = allConnections .Where(con => con.connectionId == targetConnectionId) .Select(con => con.connectionId) .ToList(); if (!targetConnectionIds.Any()) { // if next connection does not exist, no results for next. // save results to resultDict with this endpoint node's id. resultDict[dataSourceNodeId] = new Dictionary <string, List <Asset> >(); foreach (var groupKey in result.Keys) { if (!resultDict[dataSourceNodeId].ContainsKey(groupKey)) { resultDict[dataSourceNodeId][groupKey] = new List <Asset>(); } resultDict[dataSourceNodeId][groupKey].AddRange(result[groupKey]); } return; } if (!resultDict.ContainsKey(targetConnectionId)) { resultDict[targetConnectionId] = new Dictionary <string, List <Asset> >(); } /* * merge connection result by group key. */ foreach (var groupKey in result.Keys) { if (!resultDict[targetConnectionId].ContainsKey(groupKey)) { resultDict[targetConnectionId][groupKey] = new List <Asset>(); } resultDict[targetConnectionId][groupKey].AddRange(result[groupKey]); } if (isActualRun) { if (!cachedDict.ContainsKey(nodeId)) { cachedDict[nodeId] = new List <string>(); } cachedDict[nodeId].AddRange(justCached); } }; try { if (isActualRun) { switch (nodeKind) { /* * Scripts */ case AssetBundleGraphSettings.NodeKind.FILTER_SCRIPT: { var scriptClassName = currentNodeData.scriptClassName; var executor = SystemDataUtility.CreateNodeOperationInstance <FilterBase>(scriptClassName, nodeId); executor.Run(nodeName, nodeId, firstConnectionIdFromThisNodeToChildNode, inputParentResults, alreadyCachedPaths, Output); break; } case AssetBundleGraphSettings.NodeKind.PREFABRICATOR_SCRIPT: { var scriptClassName = currentNodeData.scriptClassName; var executor = SystemDataUtility.CreateNodeOperationInstance <PrefabricatorBase>(scriptClassName, nodeId); executor.Run(nodeName, nodeId, firstConnectionIdFromThisNodeToChildNode, inputParentResults, alreadyCachedPaths, Output); break; } /* * GUIs */ case AssetBundleGraphSettings.NodeKind.LOADER_GUI: { var currentLoadFilePath = SystemDataUtility.GetCurrentPlatformValue(currentNodeData.loadFilePath); var executor = new IntegratedGUILoader(FileUtility.GetPathWithAssetsPath(currentLoadFilePath)); executor.Run(nodeName, nodeId, firstConnectionIdFromThisNodeToChildNode, inputParentResults, alreadyCachedPaths, Output); break; } case AssetBundleGraphSettings.NodeKind.FILTER_GUI: { /* * Filter requires "outputPoint ordered exist connection Id and Fake connection Id" for * exhausting assets by keyword and type correctly. * * outputPoint which has connection can through assets by keyword and keytype, * also outputPoint which doesn't have connection should take assets by keyword and keytype. */ var orderedConnectionIdsAndFakeConnectionIds = new string[orderedNodeOutputPointIds.Count]; for (var i = 0; i < orderedNodeOutputPointIds.Count; i++) { var orderedNodeOutputPointId = orderedNodeOutputPointIds[i]; foreach (var nonOrderedConnectionFromThisNodeToChildNode in nonOrderedConnectionsFromThisNodeToChildNode) { var connectionOutputPointId = nonOrderedConnectionFromThisNodeToChildNode.fromNodeOutputPointId; if (orderedNodeOutputPointId == connectionOutputPointId) { orderedConnectionIdsAndFakeConnectionIds[i] = nonOrderedConnectionFromThisNodeToChildNode.connectionId; break; } else { orderedConnectionIdsAndFakeConnectionIds[i] = AssetBundleGraphSettings.FILTER_FAKE_CONNECTION_ID; } } } var executor = new IntegratedGUIFilter(orderedConnectionIdsAndFakeConnectionIds, currentNodeData.containsKeywords, currentNodeData.containsKeytypes); executor.Run(nodeName, nodeId, string.Empty, inputParentResults, alreadyCachedPaths, Output); break; } case AssetBundleGraphSettings.NodeKind.IMPORTSETTING_GUI: { var executor = new IntegratedGUIImportSetting(); executor.Run(nodeName, nodeId, firstConnectionIdFromThisNodeToChildNode, inputParentResults, alreadyCachedPaths, Output); break; } case AssetBundleGraphSettings.NodeKind.MODIFIER_GUI: { var specificScriptClass = currentNodeData.scriptClassName; var executor = new IntegratedGUIModifier(specificScriptClass, SystemDataUtility.GetCurrentPlatformShortName()); executor.Run(nodeName, nodeId, firstConnectionIdFromThisNodeToChildNode, inputParentResults, alreadyCachedPaths, Output); break; } case AssetBundleGraphSettings.NodeKind.GROUPING_GUI: { var executor = new IntegratedGUIGrouping(SystemDataUtility.GetCurrentPlatformValue(currentNodeData.groupingKeyword)); executor.Run(nodeName, nodeId, firstConnectionIdFromThisNodeToChildNode, inputParentResults, alreadyCachedPaths, Output); break; } case AssetBundleGraphSettings.NodeKind.PREFABRICATOR_GUI: { var scriptClassName = currentNodeData.scriptClassName; if (string.IsNullOrEmpty(scriptClassName)) { Debug.LogError(nodeName + ": Classname is empty. Set valid classname. Configure valid script name from editor."); break; } var executor = SystemDataUtility.CreateNodeOperationInstance <PrefabricatorBase>(scriptClassName, nodeId); executor.Run(nodeName, nodeId, firstConnectionIdFromThisNodeToChildNode, inputParentResults, alreadyCachedPaths, Output); break; } case AssetBundleGraphSettings.NodeKind.BUNDLIZER_GUI: { /* * Bundlizer requires assetOutputConnectionId and additional resourceOutputConnectionId. * both-connected, or both-not-connected, or one of them is connected. 4 patterns exists. * * Bundler Node's outputPoint [0] is always the point for assetOutputConnectionId. * Bundler Node's outputPoint [1] is always the point for resourceOutputConnectionId. * * if one of these outputPoint don't have connection, use Fake connection id for correct output. * * * unorderedConnectionId \ * ----> orderedConnectionIdsAndFakeConnectionIds. * orderedOutputPointId / */ var orderedConnectionIdsAndFakeConnectionIds = new string[orderedNodeOutputPointIds.Count]; for (var i = 0; i < orderedNodeOutputPointIds.Count; i++) { var orderedNodeOutputPointId = orderedNodeOutputPointIds[i]; foreach (var nonOrderedConnectionFromThisNodeToChildNode in nonOrderedConnectionsFromThisNodeToChildNode) { var connectionOutputPointId = nonOrderedConnectionFromThisNodeToChildNode.fromNodeOutputPointId; if (orderedNodeOutputPointId == connectionOutputPointId) { orderedConnectionIdsAndFakeConnectionIds[i] = nonOrderedConnectionFromThisNodeToChildNode.connectionId; break; } else { orderedConnectionIdsAndFakeConnectionIds[i] = AssetBundleGraphSettings.BUNDLIZER_FAKE_CONNECTION_ID; } } } var bundleNameTemplate = SystemDataUtility.GetCurrentPlatformValue(currentNodeData.bundleNameTemplate); /* * TODO: variants needs to be execute Setup/Run as many times as its variants */ var executor = new IntegratedGUIBundlizer(bundleNameTemplate, orderedConnectionIdsAndFakeConnectionIds[0], currentNodeData.variants); executor.Run(nodeName, nodeId, string.Empty, inputParentResults, alreadyCachedPaths, Output); break; } case AssetBundleGraphSettings.NodeKind.BUNDLEBUILDER_GUI: { var bundleOptions = SystemDataUtility.GetCurrentPlatformValue(currentNodeData.enabledBundleOptions); var executor = new IntegratedGUIBundleBuilder(bundleOptions, allNodes.Select(nodeData => nodeData.nodeId).ToList()); executor.Run(nodeName, nodeId, firstConnectionIdFromThisNodeToChildNode, inputParentResults, alreadyCachedPaths, Output); break; } case AssetBundleGraphSettings.NodeKind.EXPORTER_GUI: { var exportTo = SystemDataUtility.GetCurrentPlatformValue(currentNodeData.exportFilePath); var executor = new IntegratedGUIExporter(FileUtility.GetPathWithProjectPath(exportTo)); executor.Run(nodeName, nodeId, firstConnectionIdFromThisNodeToChildNode, inputParentResults, alreadyCachedPaths, Output); break; } default: { Debug.LogError(nodeName + " is defined as unknown kind of node. value:" + nodeKind); break; } } } else { switch (nodeKind) { /* * Scripts */ case AssetBundleGraphSettings.NodeKind.FILTER_SCRIPT: { var scriptClassName = currentNodeData.scriptClassName; var executor = SystemDataUtility.CreateNodeOperationInstance <FilterBase>(scriptClassName, nodeId); executor.Setup(nodeName, nodeId, firstConnectionIdFromThisNodeToChildNode, inputParentResults, alreadyCachedPaths, Output); break; } case AssetBundleGraphSettings.NodeKind.PREFABRICATOR_SCRIPT: { var scriptClassName = currentNodeData.scriptClassName; var executor = SystemDataUtility.CreateNodeOperationInstance <PrefabricatorBase>(scriptClassName, nodeId); executor.Setup(nodeName, nodeId, firstConnectionIdFromThisNodeToChildNode, inputParentResults, alreadyCachedPaths, Output); break; } /* * GUIs */ case AssetBundleGraphSettings.NodeKind.LOADER_GUI: { var currentLoadFilePath = SystemDataUtility.GetCurrentPlatformValue(currentNodeData.loadFilePath); var executor = new IntegratedGUILoader(FileUtility.GetPathWithAssetsPath(currentLoadFilePath)); executor.Setup(nodeName, nodeId, firstConnectionIdFromThisNodeToChildNode, inputParentResults, alreadyCachedPaths, Output); break; } case AssetBundleGraphSettings.NodeKind.FILTER_GUI: { /* * Filter requires "outputPoint ordered exist connection Id and Fake connection Id" for * exhausting assets by keyword and type correctly. * * outputPoint which has connection can through assets by keyword and keytype, * also outputPoint which doesn't have connection should take assets by keyword and keytype. */ var orderedConnectionIdsAndFakeConnectionIds = new string[orderedNodeOutputPointIds.Count]; for (var i = 0; i < orderedNodeOutputPointIds.Count; i++) { var orderedNodeOutputPointId = orderedNodeOutputPointIds[i]; foreach (var nonOrderedConnectionFromThisNodeToChildNode in nonOrderedConnectionsFromThisNodeToChildNode) { var connectionOutputPointId = nonOrderedConnectionFromThisNodeToChildNode.fromNodeOutputPointId; if (orderedNodeOutputPointId == connectionOutputPointId) { orderedConnectionIdsAndFakeConnectionIds[i] = nonOrderedConnectionFromThisNodeToChildNode.connectionId; break; } else { orderedConnectionIdsAndFakeConnectionIds[i] = AssetBundleGraphSettings.FILTER_FAKE_CONNECTION_ID; } } } var executor = new IntegratedGUIFilter(orderedConnectionIdsAndFakeConnectionIds, currentNodeData.containsKeywords, currentNodeData.containsKeytypes); executor.Setup(nodeName, nodeId, string.Empty, inputParentResults, alreadyCachedPaths, Output); break; } case AssetBundleGraphSettings.NodeKind.IMPORTSETTING_GUI: { var executor = new IntegratedGUIImportSetting(); executor.Setup(nodeName, nodeId, firstConnectionIdFromThisNodeToChildNode, inputParentResults, alreadyCachedPaths, Output); break; } case AssetBundleGraphSettings.NodeKind.MODIFIER_GUI: { var specificScriptClass = currentNodeData.scriptClassName; var executor = new IntegratedGUIModifier(specificScriptClass, SystemDataUtility.GetCurrentPlatformShortName()); executor.Setup(nodeName, nodeId, firstConnectionIdFromThisNodeToChildNode, inputParentResults, alreadyCachedPaths, Output); break; } case AssetBundleGraphSettings.NodeKind.GROUPING_GUI: { var executor = new IntegratedGUIGrouping(SystemDataUtility.GetCurrentPlatformValue(currentNodeData.groupingKeyword)); executor.Setup(nodeName, nodeId, firstConnectionIdFromThisNodeToChildNode, inputParentResults, alreadyCachedPaths, Output); break; } case AssetBundleGraphSettings.NodeKind.PREFABRICATOR_GUI: { var scriptClassName = currentNodeData.scriptClassName; if (string.IsNullOrEmpty(scriptClassName)) { AssetBundleGraphEditorWindow.AddNodeException(new NodeException(nodeName + ": Classname is empty. Set valid classname.", nodeId)); break; } try { var executor = SystemDataUtility.CreateNodeOperationInstance <PrefabricatorBase>(scriptClassName, nodeId); executor.Setup(nodeName, nodeId, firstConnectionIdFromThisNodeToChildNode, inputParentResults, alreadyCachedPaths, Output); } catch (NodeException e) { AssetBundleGraphEditorWindow.AddNodeException(e); break; } break; } case AssetBundleGraphSettings.NodeKind.BUNDLIZER_GUI: { /* * Bundlizer requires assetOutputConnectionId and additional resourceOutputConnectionId. * both-connected, or both-not-connected, or one of them is connected. 4 patterns exists. * * Bundler Node's outputPoint [0] is always the point for assetOutputConnectionId. * Bundler Node's outputPoint [1] is always the point for resourceOutputConnectionId. * * if one of these outputPoint don't have connection, use Fake connection id for correct output. * * * unorderedConnectionId \ * ----> orderedConnectionIdsAndFakeConnectionIds. * orderedOutputPointId / */ var orderedConnectionIdsAndFakeConnectionIds = new string[orderedNodeOutputPointIds.Count]; for (var i = 0; i < orderedNodeOutputPointIds.Count; i++) { var orderedNodeOutputPointId = orderedNodeOutputPointIds[i]; foreach (var nonOrderedConnectionFromThisNodeToChildNode in nonOrderedConnectionsFromThisNodeToChildNode) { var connectionOutputPointId = nonOrderedConnectionFromThisNodeToChildNode.fromNodeOutputPointId; if (orderedNodeOutputPointId == connectionOutputPointId) { orderedConnectionIdsAndFakeConnectionIds[i] = nonOrderedConnectionFromThisNodeToChildNode.connectionId; break; } else { orderedConnectionIdsAndFakeConnectionIds[i] = AssetBundleGraphSettings.BUNDLIZER_FAKE_CONNECTION_ID; } } } var bundleNameTemplate = SystemDataUtility.GetCurrentPlatformValue(currentNodeData.bundleNameTemplate); /* * TODO: variants needs to be execute Setup/Run as many times as its variants */ var executor = new IntegratedGUIBundlizer(bundleNameTemplate, orderedConnectionIdsAndFakeConnectionIds[0], currentNodeData.variants); executor.Setup(nodeName, nodeId, string.Empty, inputParentResults, alreadyCachedPaths, Output); break; } case AssetBundleGraphSettings.NodeKind.BUNDLEBUILDER_GUI: { var bundleOptions = SystemDataUtility.GetCurrentPlatformValue(currentNodeData.enabledBundleOptions); var executor = new IntegratedGUIBundleBuilder(bundleOptions, allNodes.Select(nodeData => nodeData.nodeId).ToList()); executor.Setup(nodeName, nodeId, firstConnectionIdFromThisNodeToChildNode, inputParentResults, alreadyCachedPaths, Output); break; } case AssetBundleGraphSettings.NodeKind.EXPORTER_GUI: { var exportTo = SystemDataUtility.GetCurrentPlatformValue(currentNodeData.exportFilePath); var executor = new IntegratedGUIExporter(FileUtility.GetPathWithProjectPath(exportTo)); executor.Setup(nodeName, nodeId, firstConnectionIdFromThisNodeToChildNode, inputParentResults, alreadyCachedPaths, Output); break; } default: { Debug.LogError(nodeName + " is defined as unknown kind of node. value:" + nodeKind); break; } } } } catch (NodeException e) { AssetBundleGraphEditorWindow.AddNodeException(e); //Debug.LogError("error occured:\"" + e.reason + "\", please check information on node."); return; //throw new AssetBundleGraphException(nodeName + ": " + e.reason); } currentNodeData.Done(); if (updateHandler != null) { updateHandler(nodeId, 1f); } }
public void Run(string nodeName, string nodeId, string unused_connectionIdToNextNode, Dictionary <string, List <Asset> > groupedSources, List <string> alreadyCached, Action <string, string, Dictionary <string, List <Asset> >, List <string> > Output) { ValidateBundleNameTemplate( bundleNameTemplate, () => { throw new AssetBundleGraphBuildException(nodeName + ": Bundle Name Template is empty."); } ); var recommendedBundleOutputDir = FileUtility.PathCombine(AssetBundleGraphSettings.BUNDLIZER_CACHE_PLACE, nodeId, SystemDataUtility.GetCurrentPlatformKey()); var outputDict = new Dictionary <string, List <Asset> >(); foreach (var groupKey in groupedSources.Keys) { var inputSources = groupedSources[groupKey]; var reservedBundlePath = BundlizeAssets(nodeName, groupKey, inputSources, recommendedBundleOutputDir, true); if (string.IsNullOrEmpty(reservedBundlePath)) { continue; } var outputSources = new List <Asset>(); var newAssetData = Asset.CreateAssetWithImportPath(reservedBundlePath); outputSources.Add(newAssetData); outputDict[groupKey] = outputSources; } if (assetsOutputConnectionId != AssetBundleGraphSettings.BUNDLIZER_FAKE_CONNECTION_ID) { Output(nodeId, assetsOutputConnectionId, outputDict, new List <string>()); } }
public string BundlizeAssets(string nodeName, string groupkey, List <Asset> sources, string recommendedBundleOutputDir, bool isRun) { var invalids = new List <string>(); foreach (var source in sources) { if (string.IsNullOrEmpty(source.importFrom)) { invalids.Add(source.absoluteAssetPath); } } if (invalids.Any()) { throw new AssetBundleGraphBuildException(nodeName + ": Invalid files to bundle. Following files need to be imported before bundlize: " + string.Join(", ", invalids.ToArray())); } var bundleName = bundleNameTemplate; /* * if contains KEYWORD_WILDCARD, use group identifier to bundlize name. */ if (bundleNameTemplate.Contains(AssetBundleGraphSettings.KEYWORD_WILDCARD)) { var templateHead = bundleNameTemplate.Split(AssetBundleGraphSettings.KEYWORD_WILDCARD)[0]; var templateTail = bundleNameTemplate.Split(AssetBundleGraphSettings.KEYWORD_WILDCARD)[1]; bundleName = (templateHead + groupkey + templateTail + "." + SystemDataUtility.GetCurrentPlatformShortName()).ToLower(); } var bundlePath = FileUtility.PathCombine(recommendedBundleOutputDir, bundleName); for (var i = 0; i < sources.Count; i++) { var source = sources[i]; // if already bundled in this running, avoid changing that name. if (source.isBundled) { continue; } if (isRun) { if (FileUtility.IsMetaFile(source.importFrom)) { continue; } var assetImporter = AssetImporter.GetAtPath(source.importFrom); if (assetImporter == null) { continue; } assetImporter.assetBundleName = bundleName; } // set as this resource is already bundled. sources[i] = Asset.DuplicateAssetWithNewStatus(sources[i], sources[i].isNew, true); } return(bundlePath); }
public void Setup(string nodeName, string nodeId, string unused_connectionIdToNextNode, Dictionary <string, List <Asset> > groupedSources, List <string> alreadyCached, Action <string, string, Dictionary <string, List <Asset> >, List <string> > Output) { try { ValidateBundleNameTemplate( bundleNameTemplate, () => { throw new NodeException(nodeName + ":Bundle Name Template is empty.", nodeId); } ); foreach (var name in variants.Values) { ValidateVariantName(name, variants.Values.ToList(), () => { throw new NodeException(nodeName + ":Variant is empty.", nodeId); }, () => { throw new NodeException(nodeName + ":Variant name cannot contain whitespace \"" + name + "\".", nodeId); }, () => { throw new NodeException(nodeName + ":Variant name already exists \"" + name + "\".", nodeId); }); } } catch (NodeException e) { AssetBundleGraphEditorWindow.AddNodeException(e); return; } var recommendedBundleOutputDir = FileUtility.PathCombine(AssetBundleGraphSettings.BUNDLIZER_CACHE_PLACE, nodeId, SystemDataUtility.GetCurrentPlatformKey()); var outputDict = new Dictionary <string, List <Asset> >(); 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 <Asset>(); var newAssetData = Asset.CreateAssetWithImportPath(reservedBundlePath); outputSources.Add(newAssetData); outputDict[groupKey] = outputSources; } if (assetsOutputConnectionId != AssetBundleGraphSettings.BUNDLIZER_FAKE_CONNECTION_ID) { Output(nodeId, assetsOutputConnectionId, outputDict, new List <string>()); } }
public static List <string> GetCachedDataByNode(BuildTarget t, NodeData node) { switch (node.Kind) { case NodeKind.IMPORTSETTING_GUI: { // no cache file exists for importSetting. return(new List <string>()); } case NodeKind.MODIFIER_GUI: { // no cache file exists for modifier. return(new List <string>()); } case NodeKind.PREFABBUILDER_GUI: { var cachedPathBase = FileUtility.PathCombine( AssetBundleGraphSettings.PREFABBUILDER_CACHE_PLACE, node.Id, SystemDataUtility.GetPathSafeTargetName(t) ); // no cache folder, no cache. if (!Directory.Exists(cachedPathBase)) { // search default platform + package cachedPathBase = FileUtility.PathCombine( AssetBundleGraphSettings.PREFABBUILDER_CACHE_PLACE, node.Id, SystemDataUtility.GetPathSafeDefaultTargetName() ); if (!Directory.Exists(cachedPathBase)) { return(new List <string>()); } } return(FileUtility.GetFilePathsInFolder(cachedPathBase)); } case NodeKind.BUNDLECONFIG_GUI: { // do nothing. break; } case NodeKind.BUNDLEBUILDER_GUI: { var cachedPathBase = FileUtility.PathCombine( AssetBundleGraphSettings.BUNDLEBUILDER_CACHE_PLACE, node.Id, SystemDataUtility.GetPathSafeTargetName(t) ); // no cache folder, no cache. if (!Directory.Exists(cachedPathBase)) { // search default platform + package cachedPathBase = FileUtility.PathCombine( AssetBundleGraphSettings.BUNDLEBUILDER_CACHE_PLACE, node.Id, SystemDataUtility.GetPathSafeDefaultTargetName() ); if (!Directory.Exists(cachedPathBase)) { return(new List <string>()); } } return(FileUtility.GetFilePathsInFolder(cachedPathBase)); } default: { // nothing to do. break; } } return(new List <string>()); }
public static string EnsurePrefabBuilderCacheDirExists(BuildTarget t, NodeData node) { var cacheDir = FileUtility.PathCombine(AssetBundleGraphSettings.PREFABBUILDER_CACHE_PLACE, node.Id, SystemDataUtility.GetPathSafeTargetName(t)); if (!Directory.Exists(cacheDir)) { Directory.CreateDirectory(cacheDir); } if (!cacheDir.EndsWith(AssetBundleGraphSettings.UNITY_FOLDER_SEPARATOR.ToString())) { cacheDir = cacheDir + AssetBundleGraphSettings.UNITY_FOLDER_SEPARATOR.ToString(); } return(cacheDir); }
public static List <string> GetCachedDataByNodeKind(AssetBundleGraphSettings.NodeKind nodeKind, string nodeId) { var platformPackageKeyCandidate = SystemDataUtility.GetCurrentPlatformKey(); switch (nodeKind) { case AssetBundleGraphSettings.NodeKind.IMPORTSETTING_GUI: { // no cache file exists for importSetting. return(new List <string>()); } case AssetBundleGraphSettings.NodeKind.MODIFIER_GUI: { // no cache file exists for modifier. return(new List <string>()); } case AssetBundleGraphSettings.NodeKind.PREFABRICATOR_SCRIPT: case AssetBundleGraphSettings.NodeKind.PREFABRICATOR_GUI: { var cachedPathBase = FileUtility.PathCombine( AssetBundleGraphSettings.PREFABRICATOR_CACHE_PLACE, nodeId, platformPackageKeyCandidate ); // no cache folder, no cache. if (!Directory.Exists(cachedPathBase)) { // search default platform + package cachedPathBase = FileUtility.PathCombine( AssetBundleGraphSettings.PREFABRICATOR_CACHE_PLACE, nodeId, SystemDataUtility.GetDefaultPlatformKey() ); if (!Directory.Exists(cachedPathBase)) { return(new List <string>()); } } return(FileUtility.FilePathsInFolder(cachedPathBase)); } case AssetBundleGraphSettings.NodeKind.BUNDLIZER_GUI: { // do nothing. break; } case AssetBundleGraphSettings.NodeKind.BUNDLEBUILDER_GUI: { var cachedPathBase = FileUtility.PathCombine( AssetBundleGraphSettings.BUNDLEBUILDER_CACHE_PLACE, nodeId, platformPackageKeyCandidate ); // no cache folder, no cache. if (!Directory.Exists(cachedPathBase)) { // search default platform + package cachedPathBase = FileUtility.PathCombine( AssetBundleGraphSettings.BUNDLEBUILDER_CACHE_PLACE, nodeId, SystemDataUtility.GetDefaultPlatformKey() ); if (!Directory.Exists(cachedPathBase)) { return(new List <string>()); } } return(FileUtility.FilePathsInFolder(cachedPathBase)); } default: { // nothing to do. break; } } return(new List <string>()); }
private void DoInspectorBundleBuilderGUI(NodeGUI node) { if (node.enabledBundleOptions == null) { return; } EditorGUILayout.HelpBox("BundleBuilder: Build asset bundles with given asset bundle settings.", MessageType.Info); UpdateNodeName(node); GUILayout.Space(10f); node.currentPlatform = UpdateCurrentPlatform(node.currentPlatform); using (new EditorGUILayout.VerticalScope(GUI.skin.box)) { var bundleOptions = SystemDataUtility.GetPlatformValue( node.enabledBundleOptions.ReadonlyDict(), node.currentPlatform ); var plartform_pakcage_key = SystemDataUtility.CreateKeyNameFromString(node.currentPlatform); for (var i = 0; i < AssetBundleGraphSettings.DefaultBundleOptionSettings.Count; i++) { var enablablekey = AssetBundleGraphSettings.DefaultBundleOptionSettings[i]; // contains keyword == enabled. if not, disabled. var isEnabled = bundleOptions.Contains(enablablekey); var result = EditorGUILayout.ToggleLeft(enablablekey, isEnabled); if (result != isEnabled) { node.BeforeSave(); var resultsDict = node.enabledBundleOptions.ReadonlyDict(); var resultList = new List <string>(); if (resultsDict.ContainsKey(plartform_pakcage_key)) { resultList = resultsDict[plartform_pakcage_key]; } if (result) { if (!resultList.Contains(enablablekey)) { var currentEnableds = new List <string>(); if (resultsDict.ContainsKey(plartform_pakcage_key)) { currentEnableds = resultsDict[plartform_pakcage_key]; } currentEnableds.Add(enablablekey); node.enabledBundleOptions.Add( SystemDataUtility.CreateKeyNameFromString(node.currentPlatform), currentEnableds ); } } if (!result) { if (resultList.Contains(enablablekey)) { var currentEnableds = new List <string>(); if (resultsDict.ContainsKey(plartform_pakcage_key)) { currentEnableds = resultsDict[plartform_pakcage_key]; } currentEnableds.Remove(enablablekey); node.enabledBundleOptions.Add( SystemDataUtility.CreateKeyNameFromString(node.currentPlatform), currentEnableds ); } } /* * Cannot use options DisableWriteTypeTree and IgnoreTypeTreeChanges at the same time. */ if (enablablekey == "Disable Write TypeTree" && result && node.enabledBundleOptions.ReadonlyDict()[SystemDataUtility.CreateKeyNameFromString(node.currentPlatform)].Contains("Ignore TypeTree Changes")) { var newEnableds = node.enabledBundleOptions.ReadonlyDict()[SystemDataUtility.CreateKeyNameFromString(node.currentPlatform)]; newEnableds.Remove("Ignore TypeTree Changes"); node.enabledBundleOptions.Add( SystemDataUtility.CreateKeyNameFromString(node.currentPlatform), newEnableds ); } if (enablablekey == "Ignore TypeTree Changes" && result && node.enabledBundleOptions.ReadonlyDict()[SystemDataUtility.CreateKeyNameFromString(node.currentPlatform)].Contains("Disable Write TypeTree")) { var newEnableds = node.enabledBundleOptions.ReadonlyDict()[SystemDataUtility.CreateKeyNameFromString(node.currentPlatform)]; newEnableds.Remove("Disable Write TypeTree"); node.enabledBundleOptions.Add( SystemDataUtility.CreateKeyNameFromString(node.currentPlatform), newEnableds ); } node.Save(); return; } } } UpdateDeleteSetting(node); }
private void DoInspectorExporterGUI(NodeGUI node) { if (node.Data.ExporterExportPath == null) { return; } EditorGUILayout.HelpBox("Exporter: Export given files to output directory.", MessageType.Info); UpdateNodeName(node); GUILayout.Space(10f); //Show target configuration tab DrawPlatformSelector(node); using (new EditorGUILayout.VerticalScope(GUI.skin.box)) { var disabledScope = DrawOverrideTargetToggle(node, node.Data.ExporterExportPath.ContainsValueOf(currentEditingGroup), (bool enabled) => { using (new RecordUndoScope("Remove Target Export Settings", node, true)){ if (enabled) { node.Data.ExporterExportPath[currentEditingGroup] = node.Data.ExporterExportPath.DefaultValue; } else { node.Data.ExporterExportPath.Remove(currentEditingGroup); } } }); using (disabledScope) { EditorGUILayout.LabelField("Export Path:"); var newExportPath = EditorGUILayout.TextField( SystemDataUtility.GetProjectName(), node.Data.ExporterExportPath[currentEditingGroup] ); var exporterrNodePath = FileUtility.GetPathWithProjectPath(newExportPath); if (IntegratedGUIExporter.ValidateExportPath( newExportPath, exporterrNodePath, () => { // TODO Make text field bold }, () => { using (new EditorGUILayout.HorizontalScope()) { EditorGUILayout.LabelField(exporterrNodePath + " does not exist."); if (GUILayout.Button("Create directory")) { using (new SaveScope(node)) { Directory.CreateDirectory(exporterrNodePath); } } } EditorGUILayout.Space(); EditorGUILayout.LabelField("Available Directories:"); string[] dirs = Directory.GetDirectories(Path.GetDirectoryName(exporterrNodePath)); foreach (string s in dirs) { EditorGUILayout.LabelField(s); } } )) { using (new EditorGUILayout.HorizontalScope()) { GUILayout.FlexibleSpace(); #if UNITY_EDITOR_OSX string buttonName = "Reveal in Finder"; #else string buttonName = "Show in Explorer"; #endif if (GUILayout.Button(buttonName)) { EditorUtility.RevealInFinder(exporterrNodePath); } } } if (newExportPath != node.Data.ExporterExportPath[currentEditingGroup]) { using (new RecordUndoScope("Change Export Path", node, true)){ node.Data.ExporterExportPath[currentEditingGroup] = newExportPath; } } } } }
private void DoInspectorExporterGUI(NodeGUI node) { if (node.exportTo == null) { return; } EditorGUILayout.HelpBox("Exporter: Export given files to output directory.", MessageType.Info); UpdateNodeName(node); GUILayout.Space(10f); node.currentPlatform = UpdateCurrentPlatform(node.currentPlatform); using (new EditorGUILayout.VerticalScope(GUI.skin.box)) { EditorGUILayout.LabelField("Export Path:"); var newExportPath = EditorGUILayout.TextField( SystemDataUtility.GetProjectName(), SystemDataUtility.GetPlatformValue( node.exportTo.ReadonlyDict(), node.currentPlatform ).ToString() ); var exporterrNodePath = FileUtility.GetPathWithProjectPath(newExportPath); if (IntegratedGUIExporter.ValidateExportPath( newExportPath, exporterrNodePath, () => { // TODO Make text field bold }, () => { using (new EditorGUILayout.HorizontalScope()) { EditorGUILayout.LabelField(exporterrNodePath + " does not exist."); if (GUILayout.Button("Create directory")) { Directory.CreateDirectory(exporterrNodePath); node.Save(); } } EditorGUILayout.Space(); EditorGUILayout.LabelField("Available Directories:"); string[] dirs = Directory.GetDirectories(Path.GetDirectoryName(exporterrNodePath)); foreach (string s in dirs) { EditorGUILayout.LabelField(s); } } )) { using (new EditorGUILayout.HorizontalScope()) { GUILayout.FlexibleSpace(); #if UNITY_EDITOR_OSX string buttonName = "Reveal in Finder"; #else string buttonName = "Show in Explorer"; #endif if (GUILayout.Button(buttonName)) { EditorUtility.RevealInFinder(exporterrNodePath); } } } if (newExportPath != SystemDataUtility.GetPlatformValue( node.exportTo.ReadonlyDict(), node.currentPlatform ).ToString() ) { node.BeforeSave(); node.exportTo.Add(SystemDataUtility.CreateKeyNameFromString(node.currentPlatform), newExportPath); node.Save(); } } UpdateDeleteSetting(node); }
public void Run(string nodeName, string connectionIdToNextNode, string labelToNext, Dictionary <string, List <Asset> > groupedSources, List <string> alreadyCached, Action <string, string, Dictionary <string, List <Asset> >, List <string> > Output) { var recommendedBundleOutputDirSource = FileUtility.PathCombine(AssetBundleGraphSettings.BUNDLEBUILDER_CACHE_PLACE, connectionIdToNextNode); var recommendedBundleOutputDir = FileUtility.PathCombine(recommendedBundleOutputDirSource, SystemDataUtility.GetCurrentPlatformKey()); if (!Directory.Exists(recommendedBundleOutputDir)) { Directory.CreateDirectory(recommendedBundleOutputDir); } /* * merge multi group into ["0"] group. */ var intendedAssetNames = new List <string>(); foreach (var groupKey in groupedSources.Keys) { var internalAssetsOfCurrentGroup = groupedSources[groupKey]; foreach (var internalAsset in internalAssetsOfCurrentGroup) { intendedAssetNames.Add(internalAsset.fileNameAndExtension); intendedAssetNames.Add(internalAsset.fileNameAndExtension + AssetBundleGraphSettings.MANIFEST_FOOTER); } } /* * platform's bundle & manifest. * e.g. iOS & iOS.manifest. */ var currentPlatform_Package_BundleFile = SystemDataUtility.GetCurrentPlatformKey(); var currentPlatform_Package_BundleFileManifest = currentPlatform_Package_BundleFile + AssetBundleGraphSettings.MANIFEST_FOOTER; intendedAssetNames.Add(currentPlatform_Package_BundleFile); intendedAssetNames.Add(currentPlatform_Package_BundleFileManifest); /* * delete not intended assets. */ foreach (var alreadyCachedPath in alreadyCached) { var cachedFileName = Path.GetFileName(alreadyCachedPath); if (intendedAssetNames.Contains(cachedFileName)) { continue; } File.Delete(alreadyCachedPath); } var assetBundleOptions = BuildAssetBundleOptions.None; foreach (var enabled in bundleOptions) { switch (enabled) { case "Uncompressed AssetBundle": { assetBundleOptions = assetBundleOptions | BuildAssetBundleOptions.UncompressedAssetBundle; break; } case "Disable Write TypeTree": { assetBundleOptions = assetBundleOptions | BuildAssetBundleOptions.DisableWriteTypeTree; break; } case "Deterministic AssetBundle": { assetBundleOptions = assetBundleOptions | BuildAssetBundleOptions.DeterministicAssetBundle; break; } case "Force Rebuild AssetBundle": { assetBundleOptions = assetBundleOptions | BuildAssetBundleOptions.ForceRebuildAssetBundle; break; } case "Ignore TypeTree Changes": { assetBundleOptions = assetBundleOptions | BuildAssetBundleOptions.IgnoreTypeTreeChanges; break; } case "Append Hash To AssetBundle Name": { assetBundleOptions = assetBundleOptions | BuildAssetBundleOptions.AppendHashToAssetBundleName; break; } #if UNITY_5_3 case "ChunkBased Compression": { assetBundleOptions = assetBundleOptions | BuildAssetBundleOptions.ChunkBasedCompression; break; } #endif } } BuildPipeline.BuildAssetBundles(recommendedBundleOutputDir, assetBundleOptions, EditorUserBuildSettings.activeBuildTarget); /* * check assumed bundlized resources and actual generated assetbundles. * * "assuned bundlized resources info from bundlizer" are contained by "actual bundlized resources". */ var outputDict = new Dictionary <string, List <Asset> >(); var outputSources = new List <Asset>(); var newAssetPaths = new List <string>(); var generatedAssetBundlePaths = FileUtility.FilePathsInFolder(recommendedBundleOutputDir); foreach (var newAssetPath in generatedAssetBundlePaths) { newAssetPaths.Add(newAssetPath); var newAssetData = Asset.CreateAssetWithImportPath(newAssetPath); outputSources.Add(newAssetData); } // compare, erase & notice. var containedAssetBundles = new List <string>(); // collect intended output. foreach (var generatedAssetPath in newAssetPaths) { var generatedAssetName = Path.GetFileName(generatedAssetPath); // collect intended assetBundle & assetBundleManifest file. foreach (var bundledName in intendedAssetNames) { if (generatedAssetName == bundledName) { containedAssetBundles.Add(generatedAssetPath); continue; } var bundleManifestName = bundledName + AssetBundleGraphSettings.MANIFEST_FOOTER; if (generatedAssetName == bundleManifestName) { containedAssetBundles.Add(generatedAssetPath); continue; } } } var diffs = newAssetPaths.Except(containedAssetBundles); foreach (var diff in diffs) { Debug.LogWarning(nodeName + ": AssetBundle " + diff + " is not intended to build. Check if unnecessary importer or prefabricator exists in the graph."); } outputDict["0"] = outputSources; var usedCache = new List <string>(alreadyCached); Output(connectionIdToNextNode, labelToNext, outputDict, usedCache); }