Skip to content

Commit b958e1d

Browse files
committed
options button added and delete button moved inside of it.
1 parent b61d047 commit b958e1d

File tree

3 files changed

+151
-17
lines changed

3 files changed

+151
-17
lines changed
173 Bytes
Loading

Assets/Editor/Editor Windows/Icons/options.png.meta

Lines changed: 127 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Editor/Editor Windows/ScriptableObjectEditorWindow.cs

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public static string[] BasicFilters
4343
// textures:
4444
private Texture2D spaceIcon;
4545
private Texture2D orientationIcon;
46-
private Texture2D deleteConfigIcon;
46+
private Texture2D ConfigOptionsIcon;
4747
private Texture2D addConfigIcon;
4848
private Texture2D refreshIcon;
4949
private Texture2D filtersIcon;
@@ -58,8 +58,8 @@ public static string[] BasicFilters
5858
GUILayoutOption[] AddConfigButtonOptions;
5959
GUIStyle buttonStyle;
6060
// delete config button styles:
61-
GUIContent deleteConfigButton;
62-
GUILayoutOption[] deleteConfigButtonOptions;
61+
GUIContent ConfigOptionsButton;
62+
GUILayoutOption[] ConfigOoptionsButtonOptions;
6363

6464
// label styles:
6565
GUIStyle centeredLabelStyle;
@@ -155,15 +155,15 @@ private void SetupButtonStyles()
155155
}
156156

157157
// 'delete config' button styles
158-
if (deleteConfigIcon != null)
158+
if (ConfigOptionsIcon != null)
159159
{
160-
deleteConfigButton = new GUIContent(deleteConfigIcon, "delete config permanently");
161-
deleteConfigButtonOptions = new GUILayoutOption[] { GUILayout.Height(20), GUILayout.Width(20) };
160+
ConfigOptionsButton = new GUIContent(ConfigOptionsIcon, "delete config permanently");
161+
ConfigOoptionsButtonOptions = new GUILayoutOption[] { GUILayout.Height(20), GUILayout.Width(20) };
162162
}
163163
else
164164
{
165-
deleteConfigButton = new GUIContent("del", "delete config permanently");
166-
deleteConfigButtonOptions = new GUILayoutOption[] { GUILayout.Width(30) };
165+
ConfigOptionsButton = new GUIContent("del", "delete config permanently");
166+
ConfigOoptionsButtonOptions = new GUILayoutOption[] { GUILayout.Width(30) };
167167
}
168168
}
169169

@@ -327,7 +327,7 @@ private void LoadIcons()
327327
{
328328
spaceIcon = AssetDatabase.LoadAssetAtPath<Texture2D>("Assets/Editor/Editor Windows/Icons/space.png");
329329
orientationIcon = AssetDatabase.LoadAssetAtPath<Texture2D>("Assets/Editor/Editor Windows/Icons/orientation.png");
330-
deleteConfigIcon = AssetDatabase.LoadAssetAtPath<Texture2D>("Assets/Editor/Editor Windows/Icons/delete.png");
330+
ConfigOptionsIcon = AssetDatabase.LoadAssetAtPath<Texture2D>("Assets/Editor/Editor Windows/Icons/options.png");
331331
addConfigIcon = AssetDatabase.LoadAssetAtPath<Texture2D>("Assets/Editor/Editor Windows/Icons/add file.png");
332332
refreshIcon = AssetDatabase.LoadAssetAtPath<Texture2D>("Assets/Editor/Editor Windows/Icons/refresh.png");
333333
filtersIcon = AssetDatabase.LoadAssetAtPath<Texture2D>("Assets/Editor/Editor Windows/Icons/filter.png");
@@ -340,9 +340,9 @@ private void LoadIcons()
340340
{
341341
Debug.LogError("orientation Icon not found in: Assets/Editor/Editor Windows/Icons/orientation.png");
342342
}
343-
if(deleteConfigIcon == null)
343+
if(ConfigOptionsIcon == null)
344344
{
345-
Debug.LogError("deleteConfig Icon not found in: Assets/Editor/Editor Windows/Icons/delete.png");
345+
Debug.LogError("ConfigOptions Icon not found in: Assets/Editor/Editor Windows/Icons/options.png");
346346
}
347347
if (addConfigIcon == null)
348348
{
@@ -446,7 +446,7 @@ private void PutPropertiesForObject_V<T>(List<T> Configs) where T : ScriptableOb
446446
EditorGUILayout.BeginHorizontal();
447447
GUIContent propertyContent = new GUIContent(fileName, fileName);
448448
EditorGUILayout.LabelField(propertyContent, EditorStyles.miniBoldLabel, GUILayout.MinWidth(PropertyMinWidth));
449-
DeleteButton(Config);
449+
OptionsButton(Config);
450450
EditorGUILayout.EndHorizontal();
451451

452452
SerializedObject serializedObject = new(Config);
@@ -490,24 +490,31 @@ private void PutPropertiesForObject_V<T>(List<T> Configs) where T : ScriptableOb
490490
}
491491
}
492492

493-
private void DeleteButton<T>(T Config) where T : ScriptableObject
493+
private void OptionsButton<T>(T Config) where T : ScriptableObject
494494
{
495495

496496
GUIStyle buttonStyle = new GUIStyle(GUI.skin.button);
497497

498-
if (deleteConfigIcon != null)
498+
if (ConfigOptionsIcon != null)
499499
{
500500
buttonStyle.padding = new RectOffset(2, 2, 2, 2);
501501
buttonStyle.imagePosition = ImagePosition.ImageOnly;
502502
}
503503

504-
if (GUILayout.Button(deleteConfigButton, buttonStyle, deleteConfigButtonOptions))
504+
if (GUILayout.Button(ConfigOptionsButton, buttonStyle, ConfigOoptionsButtonOptions))
505505
{
506-
// Delete the selected ScriptableObject asset
507-
DeleteConfig(Config);
506+
ShowOptionsMenu(Config);
508507
}
509508
}
510509

510+
private void ShowOptionsMenu<T>(T Config) where T : ScriptableObject
511+
{
512+
GenericMenu menu = new GenericMenu();
513+
514+
menu.AddItem(new GUIContent("Delete Config"), false, () => DeleteConfig(Config));
515+
516+
menu.ShowAsContext();
517+
}
511518

512519
/// <summary>
513520
/// create a Horizontal (parameters will be horizontal) table for the properties of the object

0 commit comments

Comments
 (0)