Skip to content

Commit 0a49b06

Browse files
committed
added delete button to remove scriptable objects
1 parent 67339b1 commit 0a49b06

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Assets/Editor/Editor Windows/ScriptableObjectEditorWindow.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,22 @@ private void PutPropertiesForObject<T>(List<T> Configs) where T : ScriptableObje
183183
string filePath = AssetDatabase.GetAssetPath(Config);
184184
string fileName = System.IO.Path.GetFileNameWithoutExtension(filePath);
185185
if (fileName == "") throw new System.Exception();
186+
187+
// Display the file name and a delete button for the asset
188+
EditorGUILayout.BeginHorizontal();
186189
EditorGUILayout.LabelField(fileName, EditorStyles.miniBoldLabel, GUILayout.MinWidth(PropertyMinWidth));
190+
if(GUILayout.Button("del", GUILayout.MaxWidth(30)))
191+
{
192+
// Delete the selected ScriptableObject asset
193+
if (EditorUtility.DisplayDialog("Delete Config", "Are you sure you want to delete this config?", "Yes", "No"))
194+
{
195+
AssetDatabase.DeleteAsset(AssetDatabase.GetAssetPath(Config));
196+
AssetDatabase.SaveAssets();
197+
AssetDatabase.Refresh();
198+
GroupScriptableObjectsByType(); // Refresh the list after deletion
199+
}
200+
}
201+
EditorGUILayout.EndHorizontal();
187202

188203
SerializedObject serializedObject = new SerializedObject(Config);
189204
SerializedProperty property = serializedObject.GetIterator();

0 commit comments

Comments
 (0)