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); bool bRespondAP = EditorGUILayout.ToggleLeft("Respond To Asset Change", m_respondToAssetChange); if (bRespondAP != m_respondToAssetChange) { using (new RecordUndoScope("Remove Target Load Path Settings", node, true)) { m_respondToAssetChange = bRespondAP; } } GUILayout.Space(4f); //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; m_loadPathGuid[editor.CurrentEditingGroup] = m_loadPathGuid.DefaultValue; } else { m_loadPath.Remove(editor.CurrentEditingGroup); m_loadPathGuid.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)); } ); var dirPath = Path.Combine(Model.Settings.Path.ASSETS_PATH, newLoadPath); if (newLoadPath != path) { using (new RecordUndoScope("Load Path Changed", node, true)){ m_loadPath[editor.CurrentEditingGroup] = newLoadPath; m_loadPathGuid [editor.CurrentEditingGroup] = AssetDatabase.AssetPathToGUID(dirPath); onValueChanged(); } } 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); } } } } } GUILayout.Space(8f); DrawIgnoredPatterns(node, 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; m_manifestName[editor.CurrentEditingGroup] = m_manifestName.DefaultValue; } else { m_enabledBundleOptions.Remove(editor.CurrentEditingGroup); m_outputDir.Remove(editor.CurrentEditingGroup); m_outputOption.Remove(editor.CurrentEditingGroup); m_manifestName.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(); } } var outputDir = PrepareOutputDirectory(BuildTargetUtility.GroupToTarget(editor.CurrentEditingGroup), node.Data, false, false); if (opt == OutputOption.ErrorIfNoOutputDirectoryFound && editor.CurrentEditingGroup != BuildTargetGroup.Unknown && !string.IsNullOrEmpty(m_outputDir [editor.CurrentEditingGroup]) && !Directory.Exists(outputDir)) { using (new EditorGUILayout.HorizontalScope()) { EditorGUILayout.LabelField(outputDir + " does not exist."); if (GUILayout.Button("Create directory")) { Directory.CreateDirectory(outputDir); } } 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(); } 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); } } } EditorGUILayout.HelpBox("You can use '{Platform}' variable for Output Directory path to include platform name.", MessageType.Info); } GUILayout.Space(8f); var manifestName = m_manifestName[editor.CurrentEditingGroup]; var newManifestName = EditorGUILayout.TextField("Manifest Name", manifestName); if (newManifestName != manifestName) { using (new RecordUndoScope("Change Manifest Name", node, true)){ m_manifestName[editor.CurrentEditingGroup] = newManifestName; onValueChanged(); } } GUILayout.Space(8f); 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_groupSizeByte == null) { return; } EditorGUILayout.HelpBox("Grouping by size: Create group of assets by size.", 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_groupSizeByte.ContainsValueOf(editor.CurrentEditingGroup), (bool enabled) => { using (new RecordUndoScope("Remove Target Grouping Size Settings", node, true)){ if (enabled) { m_groupSizeByte[editor.CurrentEditingGroup] = m_groupSizeByte.DefaultValue; m_groupingType[editor.CurrentEditingGroup] = m_groupingType.DefaultValue; m_groupNameFormat[editor.CurrentEditingGroup] = m_groupNameFormat.DefaultValue; } else { m_groupSizeByte.Remove(editor.CurrentEditingGroup); m_groupingType.Remove(editor.CurrentEditingGroup); m_groupNameFormat.Remove(editor.CurrentEditingGroup); } onValueChanged(); } }); using (disabledScope) { var newType = (GroupingType)EditorGUILayout.EnumPopup("Grouping Type", (GroupingType)m_groupingType[editor.CurrentEditingGroup]); if (newType != (GroupingType)m_groupingType[editor.CurrentEditingGroup]) { using (new RecordUndoScope("Change Grouping Type", node, true)){ m_groupingType[editor.CurrentEditingGroup] = (int)newType; onValueChanged(); } } var newSizeText = EditorGUILayout.TextField("Size(KB)", m_groupSizeByte[editor.CurrentEditingGroup].ToString()); int newSize = 0; Int32.TryParse(newSizeText, out newSize); if (newSize != m_groupSizeByte[editor.CurrentEditingGroup]) { using (new RecordUndoScope("Change Grouping Size", node, true)){ m_groupSizeByte[editor.CurrentEditingGroup] = newSize; onValueChanged(); } } var newGroupNameFormat = EditorGUILayout.TextField("Group Name Format", m_groupNameFormat [editor.CurrentEditingGroup]); EditorGUILayout.HelpBox( "You can customize group name. You can use variable {OldGroup} for old group name and {NewGroup} for current matching name.", MessageType.Info); if (newGroupNameFormat != m_groupNameFormat [editor.CurrentEditingGroup]) { using (new RecordUndoScope("Change Group Name", node, true)) { m_groupNameFormat [editor.CurrentEditingGroup] = newGroupNameFormat; onValueChanged(); } } } } var newFreezeGroups = EditorGUILayout.ToggleLeft("Freeze group on build", m_freezeGroups); if (newFreezeGroups != m_freezeGroups) { using (new RecordUndoScope("Change Freeze Groups", node, true)){ m_freezeGroups = newFreezeGroups; onValueChanged(); } } EditorGUILayout.HelpBox("Freezing group will save group when build is performed, and any new asset from there will be put into new group.", MessageType.Info); using (new GUILayout.HorizontalScope()) { GUILayout.Label("Group setting"); GUILayout.FlexibleSpace(); if (GUILayout.Button("Import")) { if (ImportGroupsWithGUI(node)) { onValueChanged(); } } if (GUILayout.Button("Export")) { ExportGroupsWithGUI(node); } if (GUILayout.Button("Reset")) { if (EditorUtility.DisplayDialog("Do you want to reset group setting?", "This will erase current saved group setting.", "OK", "Cancel")) { m_savedGroups = null; onValueChanged(); } } } GUILayout.Space(8f); if (m_groupViewController != null) { m_groupViewController.OnGroupViewGUI(); } }
public override void OnInspectorGUI(NodeGUI node, AssetReferenceStreamManager streamManager, NodeGUIEditor editor, Action onValueChanged) { EditorGUILayout.HelpBox("Build Addressable Assets: Build Addressable Assets.", MessageType.Info); editor.UpdateNodeName(node); GUILayout.Space(4f); EditorGUILayout.HelpBox("Build Addressable Assets does not respect Platform selection in Graph Editor." + "Instead, Addressable Profile will be used for platform targeting.", MessageType.Info); if (!AddressableAssetSettingsDefaultObject.SettingsExists) { return; } var profileNames = Settings.profileSettings.GetAllProfileNames(); profileNames.Insert(0, kCurrentProfile); var profileIndex = string.IsNullOrEmpty(m_profileName) ? 0 : profileNames.IndexOf(m_profileName); var newProfileIndex = EditorGUILayout.Popup("Profile", profileIndex, profileNames.ToArray()); if (newProfileIndex != profileIndex) { using (new RecordUndoScope("Change Profile", node, true)) { m_profileName = profileNames[newProfileIndex]; onValueChanged(); } } if (m_currentDataBuilder == null && !string.IsNullOrEmpty(m_builderGuid)) { m_currentDataBuilder = Settings.DataBuilders.FirstOrDefault(obj => AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(obj)) == m_builderGuid); } var dataBuilders = Settings.DataBuilders.Where(builder => (builder as IDataBuilder).CanBuildData <AddressablesPlayerBuildResult>()).ToList(); var builderIndex = m_currentDataBuilder == null ? -1 : dataBuilders.IndexOf(m_currentDataBuilder); var builderNames = dataBuilders .Select(builder => ((IDataBuilder)builder).Name).ToArray(); var newIndex = EditorGUILayout.Popup("Builder Script", builderIndex, builderNames); if (newIndex != builderIndex) { using (new RecordUndoScope("Change Builder", node, true)) { m_currentDataBuilder = dataBuilders[newIndex]; m_builderGuid = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(m_currentDataBuilder)); onValueChanged(); } } var newPreferUpdate = EditorGUILayout.ToggleLeft("Update", m_preferUpdate); if (newPreferUpdate != m_preferUpdate) { using (new RecordUndoScope("Update Toggle", node, true)) { m_preferUpdate = newPreferUpdate; onValueChanged(); } } using (new EditorGUI.DisabledScope(!m_preferUpdate)) { GUILayout.Label("Content State File", "BoldLabel"); using (new EditorGUILayout.HorizontalScope()) { EditorGUILayout.SelectableLabel(m_contentStateFilePath, EditorStyles.textField, GUILayout.Height(EditorGUIUtility.singleLineHeight)); if (GUILayout.Button("Select", GUILayout.Width(50f))) { var newStateData = ContentUpdateScript.GetContentStateDataPath(true); if (newStateData != null && newStateData != m_contentStateFilePath) { using (new RecordUndoScope("Content State Data Path", node, true)) { m_contentStateFilePath = newStateData; onValueChanged(); } } } } } GUILayout.Space(10f); if (GUILayout.Button("Clean Build Cache", GUILayout.Width(250f))) { if (EditorUtility.DisplayDialog("Clean Build Cache", "Do you really want to clean build cache?", "OK", "Cancel")) { AddressableAssetSettings.CleanPlayerContent(null); BuildCache.PurgeCache(false); } } }
public override void OnInspectorGUI(NodeGUI node, AssetReferenceStreamManager streamManager, NodeGUIEditor editor, Action onValueChanged) { EditorGUILayout.HelpBox("Extract Shared Assets: Extract shared assets between asset bundles and add bundle configurations.", MessageType.Info); editor.UpdateNodeName(node); GUILayout.Space(10f); var newValue = EditorGUILayout.TextField("Bundle Name Template", m_bundleNameTemplate); if (newValue != m_bundleNameTemplate) { using (new RecordUndoScope("Bundle Name Template Change", node, true)) { m_bundleNameTemplate = newValue; onValueChanged(); } } GUILayout.Space(10f); //Show target configuration tab editor.DrawPlatformSelector(node); using (new EditorGUILayout.VerticalScope(GUI.skin.box)) { var disabledScope = editor.DrawOverrideTargetToggle(node, m_groupSizeByte.ContainsValueOf(editor.CurrentEditingGroup), (bool enabled) => { using (new RecordUndoScope("Remove Target Grouping Size Settings", node, true)){ if (enabled) { m_groupExtractedAssets[editor.CurrentEditingGroup] = m_groupExtractedAssets.DefaultValue; m_groupSizeByte[editor.CurrentEditingGroup] = m_groupSizeByte.DefaultValue; m_groupingType[editor.CurrentEditingGroup] = m_groupingType.DefaultValue; } else { m_groupExtractedAssets.Remove(editor.CurrentEditingGroup); m_groupSizeByte.Remove(editor.CurrentEditingGroup); m_groupingType.Remove(editor.CurrentEditingGroup); } onValueChanged(); } }); using (disabledScope) { var useGroup = EditorGUILayout.ToggleLeft("Subgroup shared assets by size", m_groupExtractedAssets [editor.CurrentEditingGroup] != 0); if (useGroup != (m_groupExtractedAssets [editor.CurrentEditingGroup] != 0)) { using (new RecordUndoScope("Change Grouping Type", node, true)){ m_groupExtractedAssets[editor.CurrentEditingGroup] = (useGroup)? 1:0; onValueChanged(); } } using (new EditorGUI.DisabledScope(!useGroup)) { var newType = (GroupingType)EditorGUILayout.EnumPopup("Grouping Type", (GroupingType)m_groupingType[editor.CurrentEditingGroup]); if (newType != (GroupingType)m_groupingType[editor.CurrentEditingGroup]) { using (new RecordUndoScope("Change Grouping Type", node, true)){ m_groupingType[editor.CurrentEditingGroup] = (int)newType; onValueChanged(); } } var newSizeText = EditorGUILayout.TextField("Size(KB)", m_groupSizeByte[editor.CurrentEditingGroup].ToString()); int newSize = 0; Int32.TryParse(newSizeText, out newSize); if (newSize != m_groupSizeByte[editor.CurrentEditingGroup]) { using (new RecordUndoScope("Change Grouping Size", node, true)){ m_groupSizeByte[editor.CurrentEditingGroup] = newSize; onValueChanged(); } } } } } EditorGUILayout.HelpBox("Bundle Name Template replaces \'*\' with number.", MessageType.Info); }
/// <summary> /// Raises the inspector GU event. /// </summary> /// <param name="node">NodeGUI instance for this node.</param> /// <param name="streamManager">Manager instance to retrieve graph's incoming/outgoing group of assets.</param> /// <param name="editor">Helper instance to draw inspector.</param> /// <param name="onValueChanged">Action to call when OnInspectorGUI() changed value of this node.</param> public abstract void OnInspectorGUI(NodeGUI node, AssetReferenceStreamManager streamManager, NodeGUIEditor editor, Action onValueChanged);
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); } } } } } }