public override void OnInspectorGUI(NodeGUI node, AssetReferenceStreamManager streamManager, NodeGUIEditor editor, Action onValueChanged) { EditorGUILayout.HelpBox("Build Player: Build Player.", MessageType.Info); editor.UpdateNodeName(node); if (m_buildOptions == null) { return; } GUILayout.Space(10f); //Show target configuration tab editor.DrawPlatformSelector(node); using (new EditorGUILayout.VerticalScope(GUI.skin.box)) { var disabledScope = editor.DrawOverrideTargetToggle(node, m_buildOptions.ContainsValueOf(editor.CurrentEditingGroup), (bool enabled) => { using (new RecordUndoScope("Remove Target Build Settings", node, true)) { if (enabled) { m_buildOptions[editor.CurrentEditingGroup] = m_buildOptions.DefaultValue; m_buildLocations[editor.CurrentEditingGroup] = m_buildLocations.DefaultValue; m_playerName[editor.CurrentEditingGroup] = m_playerName.DefaultValue; m_scenes[editor.CurrentEditingGroup] = m_scenes.DefaultValue; } else { m_buildOptions.Remove(editor.CurrentEditingGroup); m_buildLocations.Remove(editor.CurrentEditingGroup); m_playerName.Remove(editor.CurrentEditingGroup); m_scenes.Remove(editor.CurrentEditingGroup); } onValueChanged(); } }); using (disabledScope) { using (var scrollScope = new EditorGUILayout.ScrollViewScope(m_scroll)) { m_scroll = scrollScope.scrollPosition; GUILayout.Label("Player Build Location", "BoldLabel"); var newBuildLocation = editor.DrawFolderSelector("", "Select Build Location", m_buildLocations[editor.CurrentEditingGroup], Application.dataPath + "/../" ); if (newBuildLocation.StartsWith(Application.dataPath)) { throw new NodeException("You can not build player inside Assets directory.", node.Id); } if (newBuildLocation != m_buildLocations[editor.CurrentEditingGroup]) { using (new RecordUndoScope("Change Build Location", node, true)) { m_buildLocations[editor.CurrentEditingGroup] = newBuildLocation; onValueChanged(); } } GUILayout.Space(4f); var newPlayerName = EditorGUILayout.TextField("Player Name", m_playerName[editor.CurrentEditingGroup]); if (newPlayerName != m_playerName[editor.CurrentEditingGroup]) { using (new RecordUndoScope("Change Player Name", node, true)) { m_playerName[editor.CurrentEditingGroup] = newPlayerName; onValueChanged(); } } GUILayout.Space(10f); GUILayout.Label("Build Options", "BoldLabel"); int buildOptions = m_buildOptions[editor.CurrentEditingGroup]; foreach (var option in Model.Settings.BuildPlayerOptionsSettings) { // contains keyword == enabled. if not, disabled. bool isEnabled = (buildOptions & (int)option.option) != 0; var result = EditorGUILayout.ToggleLeft(option.description, isEnabled); if (result != isEnabled) { using (new RecordUndoScope("Change Build Option", node, true)) { buildOptions = (result) ? ((int)option.option | buildOptions) : (((~(int)option.option)) & buildOptions); m_buildOptions[editor.CurrentEditingGroup] = buildOptions; onValueChanged(); } } } var scenesInProject = AssetDatabase.FindAssets("t:Scene"); if (scenesInProject.Length > 0) { GUILayout.Space(10f); GUILayout.Label("Scenes", "BoldLabel"); using (new EditorGUILayout.VerticalScope(GUI.skin.box)) { var scenesSelected = m_scenes[editor.CurrentEditingGroup].Split(','); foreach (var sceneGUID in scenesInProject) { var path = AssetDatabase.GUIDToAssetPath(sceneGUID); if (string.IsNullOrEmpty(path)) { ArrayUtility.Remove(ref scenesSelected, sceneGUID); m_scenes[editor.CurrentEditingGroup] = string.Join(",", scenesSelected); onValueChanged(); continue; } var type = TypeUtility.GetTypeOfAsset(path); if (type != typeof(UnityEditor.SceneAsset)) { continue; } var selected = scenesSelected.Contains(sceneGUID); var newSelected = EditorGUILayout.ToggleLeft(path, selected); if (newSelected != selected) { using (new RecordUndoScope("Change Scene Selection", node, true)) { if (newSelected) { ArrayUtility.Add(ref scenesSelected, sceneGUID); } else { ArrayUtility.Remove(ref scenesSelected, sceneGUID); } m_scenes[editor.CurrentEditingGroup] = string.Join(",", scenesSelected); onValueChanged(); } } } } } } } } }
public override void OnInspectorGUI(NodeGUI node, AssetReferenceStreamManager streamManager, NodeGUIEditor editor, Action onValueChanged) { if (m_enabledBundleOptions == null) { return; } EditorGUILayout.HelpBox("Build Asset Bundles: Build asset bundles with given asset bundle settings.", MessageType.Info); editor.UpdateNodeName(node); bool newOverwrite = EditorGUILayout.ToggleLeft("Keep AssetImporter settings for variants", m_overwriteImporterSetting); if (newOverwrite != m_overwriteImporterSetting) { using (new RecordUndoScope("Remove Target Bundle Options", node, true)){ m_overwriteImporterSetting = newOverwrite; onValueChanged(); } } GUILayout.Space(10f); //Show target configuration tab editor.DrawPlatformSelector(node); using (new EditorGUILayout.VerticalScope(GUI.skin.box)) { var disabledScope = editor.DrawOverrideTargetToggle(node, m_enabledBundleOptions.ContainsValueOf(editor.CurrentEditingGroup), (bool enabled) => { using (new RecordUndoScope("Remove Target Bundle Options", node, true)){ if (enabled) { m_enabledBundleOptions[editor.CurrentEditingGroup] = m_enabledBundleOptions.DefaultValue; m_outputDir[editor.CurrentEditingGroup] = m_outputDir.DefaultValue; m_outputOption[editor.CurrentEditingGroup] = m_outputOption.DefaultValue; } else { m_enabledBundleOptions.Remove(editor.CurrentEditingGroup); m_outputDir.Remove(editor.CurrentEditingGroup); m_outputOption.Remove(editor.CurrentEditingGroup); } onValueChanged(); } }); using (disabledScope) { OutputOption opt = (OutputOption)m_outputOption[editor.CurrentEditingGroup]; var newOption = (OutputOption)EditorGUILayout.EnumPopup("Output Option", opt); if (newOption != opt) { using (new RecordUndoScope("Change Output Option", node, true)){ m_outputOption[editor.CurrentEditingGroup] = (int)newOption; onValueChanged(); } } using (new EditorGUI.DisabledScope(opt == OutputOption.BuildInCacheDirectory)) { var newDirPath = editor.DrawFolderSelector("Output Directory", "Select Output Folder", m_outputDir[editor.CurrentEditingGroup], Application.dataPath + "/../", (string folderSelected) => { var projectPath = Directory.GetParent(Application.dataPath).ToString(); if (projectPath == folderSelected) { folderSelected = string.Empty; } else { var index = folderSelected.IndexOf(projectPath); if (index >= 0) { folderSelected = folderSelected.Substring(projectPath.Length + index); if (folderSelected.IndexOf('/') == 0) { folderSelected = folderSelected.Substring(1); } } } return(folderSelected); } ); if (newDirPath != m_outputDir[editor.CurrentEditingGroup]) { using (new RecordUndoScope("Change Output Directory", node, true)){ m_outputDir[editor.CurrentEditingGroup] = newDirPath; onValueChanged(); } } if (opt == OutputOption.ErrorIfNoOutputDirectoryFound && !string.IsNullOrEmpty(m_outputDir [editor.CurrentEditingGroup]) && !Directory.Exists(m_outputDir [editor.CurrentEditingGroup])) { using (new EditorGUILayout.HorizontalScope()) { EditorGUILayout.LabelField(m_outputDir[editor.CurrentEditingGroup] + " does not exist."); if (GUILayout.Button("Create directory")) { Directory.CreateDirectory(m_outputDir[editor.CurrentEditingGroup]); } } EditorGUILayout.Space(); string parentDir = Path.GetDirectoryName(m_outputDir[editor.CurrentEditingGroup]); if (Directory.Exists(parentDir)) { EditorGUILayout.LabelField("Available Directories:"); string[] dirs = Directory.GetDirectories(parentDir); foreach (string s in dirs) { EditorGUILayout.LabelField(s); } } EditorGUILayout.Space(); } var outputDir = PrepareOutputDirectory(BuildTargetUtility.GroupToTarget(editor.CurrentEditingGroup), node.Data, false, false); using (new EditorGUI.DisabledScope(!Directory.Exists(outputDir))) { 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(outputDir); } } } } int bundleOptions = m_enabledBundleOptions[editor.CurrentEditingGroup]; bool isDisableWriteTypeTreeEnabled = 0 < (bundleOptions & (int)BuildAssetBundleOptions.DisableWriteTypeTree); bool isIgnoreTypeTreeChangesEnabled = 0 < (bundleOptions & (int)BuildAssetBundleOptions.IgnoreTypeTreeChanges); // buildOptions are validated during loading. Two flags should not be true at the same time. UnityEngine.Assertions.Assert.IsFalse(isDisableWriteTypeTreeEnabled && isIgnoreTypeTreeChangesEnabled); bool isSomethingDisabled = isDisableWriteTypeTreeEnabled || isIgnoreTypeTreeChangesEnabled; foreach (var option in Model.Settings.BundleOptionSettings) { // contains keyword == enabled. if not, disabled. bool isEnabled = (bundleOptions & (int)option.option) != 0; bool isToggleDisabled = (option.option == BuildAssetBundleOptions.DisableWriteTypeTree && isIgnoreTypeTreeChangesEnabled) || (option.option == BuildAssetBundleOptions.IgnoreTypeTreeChanges && isDisableWriteTypeTreeEnabled); using (new EditorGUI.DisabledScope(isToggleDisabled)) { var result = EditorGUILayout.ToggleLeft(option.description, isEnabled); if (result != isEnabled) { using (new RecordUndoScope("Change Bundle Options", node, true)){ bundleOptions = (result) ? ((int)option.option | bundleOptions) : (((~(int)option.option)) & bundleOptions); m_enabledBundleOptions[editor.CurrentEditingGroup] = bundleOptions; onValueChanged(); } } } } if (isSomethingDisabled) { EditorGUILayout.HelpBox("'Disable Write Type Tree' and 'Ignore Type Tree Changes' can not be used together.", MessageType.Info); } } } }
public override void OnInspectorGUI(NodeGUI node, AssetReferenceStreamManager streamManager, NodeGUIEditor editor, Action onValueChanged) { if (m_srcPath == null) { return; } var currentEditingGroup = editor.CurrentEditingGroup; EditorGUILayout.HelpBox("Mirror Directory: Mirror source directory to destination. This node does not use assets passed by.", MessageType.Info); editor.UpdateNodeName(node); GUILayout.Space(10f); //Show target configuration tab editor.DrawPlatformSelector(node); using (new EditorGUILayout.VerticalScope(GUI.skin.box)) { var disabledScope = editor.DrawOverrideTargetToggle(node, m_srcPath.ContainsValueOf(currentEditingGroup), (bool enabled) => { using (new RecordUndoScope("Remove Target Mirror Directory Settings", node, true)){ if (enabled) { m_srcPath[currentEditingGroup] = m_srcPath.DefaultValue; m_dstPath[currentEditingGroup] = m_dstPath.DefaultValue; m_mirrorOption[currentEditingGroup] = m_mirrorOption.DefaultValue; } else { m_srcPath.Remove(currentEditingGroup); m_dstPath.Remove(currentEditingGroup); m_mirrorOption[currentEditingGroup] = m_mirrorOption.DefaultValue; } onValueChanged(); } }); using (disabledScope) { MirrorOption opt = (MirrorOption)m_mirrorOption[currentEditingGroup]; var newOption = (MirrorOption)EditorGUILayout.EnumPopup("Mirror Option", opt); if (newOption != opt) { using (new RecordUndoScope("Change Mirror Option", node, true)){ m_mirrorOption[currentEditingGroup] = (int)newOption; onValueChanged(); } } EditorGUILayout.LabelField("Source Directory Path:"); string newSrcPath = null; string newDstPath = null; newSrcPath = editor.DrawFolderSelector("", "Select Source Folder", m_srcPath[currentEditingGroup], Directory.GetParent(Application.dataPath).ToString(), (string folderSelected) => { var projectPath = Directory.GetParent(Application.dataPath).ToString(); if (projectPath == folderSelected) { folderSelected = string.Empty; } else { var index = folderSelected.IndexOf(projectPath); if (index >= 0) { folderSelected = folderSelected.Substring(projectPath.Length + index); if (folderSelected.IndexOf('/') == 0) { folderSelected = folderSelected.Substring(1); } } } return(folderSelected); } ); if (newSrcPath != m_srcPath[currentEditingGroup]) { using (new RecordUndoScope("Change Source Folder", node, true)){ m_srcPath[currentEditingGroup] = newSrcPath; onValueChanged(); } } DrawDirectorySuggestion(GetNormalizedPath(m_srcPath[currentEditingGroup]), currentEditingGroup, onValueChanged); GUILayout.Space(10f); EditorGUILayout.LabelField("Destination Directory Path:"); newDstPath = editor.DrawFolderSelector("", "Select Destination Folder", m_dstPath[currentEditingGroup], Directory.GetParent(Application.dataPath).ToString(), (string folderSelected) => { var projectPath = Directory.GetParent(Application.dataPath).ToString(); if (projectPath == folderSelected) { folderSelected = string.Empty; } else { var index = folderSelected.IndexOf(projectPath); if (index >= 0) { folderSelected = folderSelected.Substring(projectPath.Length + index); if (folderSelected.IndexOf('/') == 0) { folderSelected = folderSelected.Substring(1); } } } return(folderSelected); } ); if (newDstPath != m_dstPath[currentEditingGroup]) { using (new RecordUndoScope("Change Destination Folder", node, true)){ m_dstPath[currentEditingGroup] = newDstPath; onValueChanged(); } } DrawDirectorySuggestion(GetNormalizedPath(m_dstPath[currentEditingGroup]), currentEditingGroup, onValueChanged); } } }
public override void OnInspectorGUI(NodeGUI node, AssetReferenceStreamManager streamManager, NodeGUIEditor editor, Action onValueChanged) { if (m_loadPath == null) { return; } EditorGUILayout.HelpBox("Load From Directory: Load assets from given directory path.", MessageType.Info); editor.UpdateNodeName(node); GUILayout.Space(10f); //Show target configuration tab editor.DrawPlatformSelector(node); using (new EditorGUILayout.VerticalScope(GUI.skin.box)) { var disabledScope = editor.DrawOverrideTargetToggle(node, m_loadPath.ContainsValueOf(editor.CurrentEditingGroup), (bool b) => { using (new RecordUndoScope("Remove Target Load Path Settings", node, true)) { if (b) { m_loadPath[editor.CurrentEditingGroup] = m_loadPath.DefaultValue; } else { m_loadPath.Remove(editor.CurrentEditingGroup); } onValueChanged(); } }); using (disabledScope) { var path = m_loadPath[editor.CurrentEditingGroup]; EditorGUILayout.LabelField("Load Path:"); string newLoadPath = null; newLoadPath = editor.DrawFolderSelector(Model.Settings.Path.ASSETS_PATH, "Select Asset Folder", path, FileUtility.PathCombine(Model.Settings.Path.ASSETS_PATH, path), (string folderSelected) => { return(NormalizeLoadPath(folderSelected)); } ); if (newLoadPath != path) { using (new RecordUndoScope("Load Path Changed", node, true)){ m_loadPath[editor.CurrentEditingGroup] = newLoadPath; onValueChanged(); } } var dirPath = Path.Combine(Model.Settings.Path.ASSETS_PATH, newLoadPath); bool dirExists = Directory.Exists(dirPath); GUILayout.Space(10f); using (new EditorGUILayout.HorizontalScope()) { using (new EditorGUI.DisabledScope(string.IsNullOrEmpty(newLoadPath) || !dirExists)) { GUILayout.FlexibleSpace(); if (GUILayout.Button("Highlight in Project Window", GUILayout.Width(180f))) { // trailing is "/" not good for LoadMainAssetAtPath if (dirPath[dirPath.Length - 1] == '/') { dirPath = dirPath.Substring(0, dirPath.Length - 1); } var obj = AssetDatabase.LoadMainAssetAtPath(dirPath); EditorGUIUtility.PingObject(obj); } } } if (!dirExists) { var parentDirPath = Path.GetDirectoryName(dirPath); bool parentDirExists = Directory.Exists(parentDirPath); if (parentDirExists) { EditorGUILayout.LabelField("Available Directories:"); string[] dirs = Directory.GetDirectories(parentDirPath); foreach (string s in dirs) { EditorGUILayout.LabelField(s); } } } } } }
public override void OnInspectorGUI(NodeGUI node, AssetReferenceStreamManager streamManager, NodeGUIEditor editor, Action onValueChanged) { EditorGUILayout.HelpBox("Assert Unwanted Assets In Bundle: Checks if unwanted assets are included in bundle configurations.", MessageType.Info); editor.UpdateNodeName(node); GUILayout.Space(10f); var newValue = (AssertionStyle)EditorGUILayout.EnumPopup("Assertion Style", m_style); if (newValue != m_style) { using (new RecordUndoScope("Change Assertion Style", node, true)) { m_style = newValue; onValueChanged(); } } GUILayout.Space(4f); //Show target configuration tab editor.DrawPlatformSelector(node); using (new EditorGUILayout.VerticalScope(GUI.skin.box)) { var disabledScope = editor.DrawOverrideTargetToggle(node, m_path.ContainsValueOf(editor.CurrentEditingGroup), (bool b) => { using (new RecordUndoScope("Remove Target Load Path Settings", node, true)) { if (b) { m_path[editor.CurrentEditingGroup] = m_path.DefaultValue; } else { m_path.Remove(editor.CurrentEditingGroup); } onValueChanged(); } }); using (disabledScope) { var path = m_path[editor.CurrentEditingGroup]; EditorGUILayout.LabelField("Assertion Path:"); string newLoadPath = null; newLoadPath = editor.DrawFolderSelector(Model.Settings.Path.ASSETS_PATH, "Select Asset Folder", path, FileUtility.PathCombine(Model.Settings.Path.ASSETS_PATH, path), (string folderSelected) => { var dataPath = Application.dataPath; if (dataPath == folderSelected) { folderSelected = string.Empty; } else { var index = folderSelected.IndexOf(dataPath); if (index >= 0) { folderSelected = folderSelected.Substring(dataPath.Length + index); if (folderSelected.IndexOf('/') == 0) { folderSelected = folderSelected.Substring(1); } } } return(folderSelected); } ); if (newLoadPath != path) { using (new RecordUndoScope("Path Change", node, true)){ m_path[editor.CurrentEditingGroup] = newLoadPath; onValueChanged(); } } var dirPath = Path.Combine(Model.Settings.Path.ASSETS_PATH, newLoadPath); bool dirExists = Directory.Exists(dirPath); GUILayout.Space(10f); using (new EditorGUILayout.HorizontalScope()) { using (new EditorGUI.DisabledScope(string.IsNullOrEmpty(newLoadPath) || !dirExists)) { GUILayout.FlexibleSpace(); if (GUILayout.Button("Highlight in Project Window", GUILayout.Width(180f))) { // trailing is "/" not good for LoadMainAssetAtPath if (dirPath[dirPath.Length - 1] == '/') { dirPath = dirPath.Substring(0, dirPath.Length - 1); } var obj = AssetDatabase.LoadMainAssetAtPath(dirPath); EditorGUIUtility.PingObject(obj); } } } } } }
public override void OnInspectorGUI(NodeGUI node, AssetReferenceStreamManager streamManager, NodeGUIEditor editor, Action onValueChanged) { if (m_exportPath == null) { return; } var currentEditingGroup = editor.CurrentEditingGroup; EditorGUILayout.HelpBox("Export To Directory: Export given files to output directory.", MessageType.Info); editor.UpdateNodeName(node); GUILayout.Space(10f); //Show target configuration tab editor.DrawPlatformSelector(node); using (new EditorGUILayout.VerticalScope(GUI.skin.box)) { var disabledScope = editor.DrawOverrideTargetToggle(node, m_exportPath.ContainsValueOf(currentEditingGroup), (bool enabled) => { using (new RecordUndoScope("Remove Target Export Settings", node, true)){ if (enabled) { m_exportPath[currentEditingGroup] = m_exportPath.DefaultValue; m_exportOption[currentEditingGroup] = m_exportOption.DefaultValue; m_flattenDir[currentEditingGroup] = m_flattenDir.DefaultValue; } else { m_exportPath.Remove(currentEditingGroup); m_exportOption.Remove(currentEditingGroup); m_flattenDir.Remove(currentEditingGroup); } onValueChanged(); } }); using (disabledScope) { ExportOption opt = (ExportOption)m_exportOption[currentEditingGroup]; var newOption = (ExportOption)EditorGUILayout.EnumPopup("Export Option", opt); if (newOption != opt) { using (new RecordUndoScope("Change Export Option", node, true)){ m_exportOption[currentEditingGroup] = (int)newOption; onValueChanged(); } } EditorGUILayout.LabelField("Export Path:"); string newExportPath = null; newExportPath = editor.DrawFolderSelector("", "Select Export Folder", m_exportPath[currentEditingGroup], GetExportPath(m_exportPath[currentEditingGroup]), (string folderSelected) => { var projectPath = Directory.GetParent(Application.dataPath).ToString(); if (projectPath == folderSelected) { folderSelected = string.Empty; } else { var index = folderSelected.IndexOf(projectPath); if (index >= 0) { folderSelected = folderSelected.Substring(projectPath.Length + index); if (folderSelected.IndexOf('/') == 0) { folderSelected = folderSelected.Substring(1); } } } return(folderSelected); } ); if (newExportPath != m_exportPath[currentEditingGroup]) { using (new RecordUndoScope("Change Export Path", node, true)){ m_exportPath[currentEditingGroup] = newExportPath; onValueChanged(); } } int flat = m_flattenDir[currentEditingGroup]; var newFlat = EditorGUILayout.ToggleLeft("Flatten Directory", flat == 1) ? 1:0; if (newFlat != flat) { using (new RecordUndoScope("Change Flatten Directory", node, true)){ m_flattenDir[currentEditingGroup] = newFlat; onValueChanged(); } } var exporterNodePath = GetExportPath(newExportPath); if (ValidateExportPath( newExportPath, exporterNodePath, () => { }, () => { using (new EditorGUILayout.HorizontalScope()) { EditorGUILayout.LabelField(exporterNodePath + " does not exist."); if (GUILayout.Button("Create directory")) { Directory.CreateDirectory(exporterNodePath); } onValueChanged(); } EditorGUILayout.Space(); string parentDir = Path.GetDirectoryName(exporterNodePath); if (Directory.Exists(parentDir)) { EditorGUILayout.LabelField("Available Directories:"); string[] dirs = Directory.GetDirectories(parentDir); foreach (string s in dirs) { EditorGUILayout.LabelField(s); } } } )) { GUILayout.Space(10f); 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(exporterNodePath); } } } } } }