public override void OnInspectorGUI(NodeGUI node, AssetReferenceStreamManager streamManager, NodeGUIEditor editor, Action onValueChanged) { EditorGUILayout.HelpBox("Overwrite Import Setting: Overwrite import settings of incoming assets.", MessageType.Info); editor.UpdateNodeName(node); GUILayout.Space(10f); // prevent inspector flicking by new Editor changing active selction node.SetActive(true); /* * importer node has no platform key. * platform key is contained by Unity's importer inspector itself. */ using (new EditorGUILayout.VerticalScope()) { Type incomingType = TypeUtility.FindFirstIncomingAssetType(streamManager, node.Data.InputPoints[0]); ImportSetting.ConfigStatus status = ImportSetting.GetConfigStatus(node.Data); if (incomingType == null) { // try to retrieve incoming type from configuration if (status == ImportSetting.ConfigStatus.GoodSampleFound) { incomingType = GetReferenceAssetImporter(node.Data, false).GetType(); } else { using (new EditorGUILayout.VerticalScope(GUI.skin.box)) { EditorGUILayout.HelpBox("Import setting type can be set by incoming asset, or you can specify by selecting.", MessageType.Info); using (new EditorGUILayout.HorizontalScope()) { EditorGUILayout.LabelField("Importer Type"); if (GUILayout.Button("", "Popup", GUILayout.MinWidth(150f))) { var menu = new GenericMenu(); for (var i = 0; i < s_importerTypeList.Length; i++) { var index = i; menu.AddItem( new GUIContent(s_importerTypeList [i]), false, () => { ResetConfig(node.Data); var configFilePath = FileUtility.GetImportSettingTemplateFilePath(s_importerTypeList [index]); SaveSampleFile(node.Data, configFilePath); } ); } menu.ShowAsContext(); } } } return; } } switch (status) { case ImportSetting.ConfigStatus.NoSampleFound: // ImportSetting.Setup() must run to grab another sample to configure. EditorGUILayout.HelpBox("Press Refresh to configure.", MessageType.Info); node.Data.NeedsRevisit = true; break; case ImportSetting.ConfigStatus.GoodSampleFound: if (m_importerEditor == null) { var importer = GetReferenceAssetImporter(node.Data, true); if (importer != null) { m_importerEditor = Editor.CreateEditor(importer); } } // Custom Sprite Packing Tag if (incomingType == typeof(UnityEditor.TextureImporter)) { using (new EditorGUILayout.VerticalScope(GUI.skin.box)) { m_overwritePackingTag = EditorGUILayout.ToggleLeft("Configure Sprite Packing Tag", m_overwritePackingTag); if (m_overwritePackingTag) { var val = m_spritePackingTagNameTemplate [editor.CurrentEditingGroup]; var newValue = EditorGUILayout.TextField("Packing Tag", val); if (newValue != val) { using (new RecordUndoScope("Change Packing Tag", node, true)) { m_spritePackingTagNameTemplate [editor.CurrentEditingGroup] = newValue; onValueChanged(); } } } EditorGUILayout.HelpBox( "You can configure packing tag name with \"*\" to include group name in your sprite tag.", MessageType.Info); } GUILayout.Space(10); } // Custom Sample Asset using (new EditorGUILayout.VerticalScope(GUI.skin.box)) { var newUseCustomAsset = EditorGUILayout.ToggleLeft("Use Custom Setting Asset", m_useCustomSettingAsset); if (newUseCustomAsset != m_useCustomSettingAsset) { using (new RecordUndoScope("Change Custom Setting Asset", node, true)) { m_useCustomSettingAsset = newUseCustomAsset; onValueChanged(); if (m_importerEditor != null) { UnityEngine.Object.DestroyImmediate(m_importerEditor); m_importerEditor = null; } } } if (m_useCustomSettingAsset) { var assetType = GetAssetTypeFromImporterType(incomingType); if (assetType != null) { var newObject = EditorGUILayout.ObjectField("Asset", CustomSettingAsset, assetType, false); if (incomingType == typeof(ModelImporter)) { // disallow selecting non-model prefab if (PrefabUtility.GetPrefabType(newObject) != PrefabType.ModelPrefab) { newObject = CustomSettingAsset; } } if (newObject != CustomSettingAsset) { using (new RecordUndoScope("Change Custom Setting Asset", node, true)) { CustomSettingAsset = newObject; onValueChanged(); if (m_importerEditor != null) { UnityEngine.Object.DestroyImmediate(m_importerEditor); m_importerEditor = null; } } } if (CustomSettingAsset != null) { using (new EditorGUILayout.HorizontalScope()) { GUILayout.FlexibleSpace(); if (GUILayout.Button("Highlight in Project Window", GUILayout.Width(180f))) { EditorGUIUtility.PingObject(CustomSettingAsset); } } } } else { EditorGUILayout.HelpBox( "Incoming asset type is not supported. Please fix issue first or clear the saved import setting.", MessageType.Error); if (m_importerEditor != null) { UnityEngine.Object.DestroyImmediate(m_importerEditor); m_importerEditor = null; } } } EditorGUILayout.HelpBox( "Custom setting asset is useful when you need specific needs for setting asset; i.e. when configuring with multiple sprite mode.", MessageType.Info); } GUILayout.Space(10); if (m_importerEditor != null) { GUILayout.Label(string.Format("Import Setting ({0})", incomingType.Name)); m_importerEditor.OnInspectorGUI(); GUILayout.Space(40); } using (new EditorGUILayout.HorizontalScope(GUI.skin.box)) { GUILayout.Space(4); EditorGUILayout.LabelField("Clear Saved Import Setting"); if (GUILayout.Button("Clear")) { if (EditorUtility.DisplayDialog("Clear Saved Import Setting", string.Format("Do you want to reset saved import setting for \"{0}\"? This operation is not undoable.", node.Name), "OK", "Cancel")) { ResetConfig(node.Data); } } } break; case ImportSetting.ConfigStatus.TooManySamplesFound: if (GUILayout.Button("Reset Import Setting")) { ResetConfig(node.Data); } break; } } return; }
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_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); } } } } } }