Skip to content

Commit 75087cc

Browse files
authored
Merge pull request #152 from brunomikoski/feature/more-qol-fixes
Feature/more qol fixes
2 parents cde9910 + 9c72093 commit 75087cc

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

CHANGELOG.MD

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88
## Changed
99
- Update PickerPropertyDrawer to use PopupList from property path cache to avoid issue when rendered inside a List/Array
1010
- Update CollectionRegistry to search for the ScriptableObjectCollection using the `AssetDatabase.FindAssets` instead of the `TypeCache` first
11+
- Added confirmation popup for deleting items from the Collection
12+
- Fixed issue while renaming one asset could be canceled on arrow keys press
1113

1214
## [2.3.3]
1315
## Added

Scripts/Editor/CustomEditors/CollectionCustomEditor.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,9 @@ private void BindCollectionItemListItem(VisualElement targetElement, int targetI
298298

299299
private void OnKeyUpOnCollectionListView(KeyUpEvent evt)
300300
{
301+
if (currentRenamingLabel != null)
302+
return;
303+
301304
switch (evt.keyCode)
302305
{
303306
case KeyCode.F2:
@@ -648,6 +651,12 @@ protected void DeleteItemAtIndex(int selectedIndex)
648651
return;
649652
}
650653

654+
if (!EditorUtility.DisplayDialog($"Delete {scriptableObject.name}",
655+
$"Are you sure you want to delete {scriptableObject.name}?", "Yes", "No"))
656+
{
657+
return;
658+
}
659+
651660
Undo.RecordObject(collection, "Remove Item");
652661

653662
filteredItems.Remove(scriptableObject);

Scripts/Runtime/Utils/AssetDatabaseUtils.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,18 @@ public static void CreatePathIfDoesntExist(string targetPath)
2121
public static void RenameAsset(Object targetObject, string newName)
2222
{
2323
#if UNITY_EDITOR
24-
UnityEditor.AssetDatabase.RenameAsset(UnityEditor.AssetDatabase.GetAssetPath(targetObject), newName);
25-
targetObject.name = newName;
24+
string assetPath = UnityEditor.AssetDatabase.GetAssetPath(targetObject);
25+
26+
string guid = UnityEditor.AssetDatabase.AssetPathToGUID(assetPath);
27+
UnityEditor.Undo.SetCurrentGroupName($"Rename Asset from {targetObject.name} to {newName}");
28+
UnityEditor.Undo.RecordObject(targetObject, "Rename Asset");
29+
30+
UnityEditor.AssetDatabase.RenameAsset(assetPath, newName);
31+
32+
UnityEditor.Undo.CollapseUndoOperations(UnityEditor.Undo.GetCurrentGroup());
2633
ObjectUtility.SetDirty(targetObject);
34+
UnityEditor.AssetDatabase.ImportAsset(UnityEditor.AssetDatabase.GUIDToAssetPath(guid));
2735
#endif
2836
}
2937
}
30-
}
38+
}

0 commit comments

Comments
 (0)