Skip to content

Commit

Permalink
Merge pull request #152 from brunomikoski/feature/more-qol-fixes
Browse files Browse the repository at this point in the history
Feature/more qol fixes
  • Loading branch information
brunomikoski authored Aug 14, 2024
2 parents cde9910 + 9c72093 commit 75087cc
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Changed
- Update PickerPropertyDrawer to use PopupList from property path cache to avoid issue when rendered inside a List/Array
- Update CollectionRegistry to search for the ScriptableObjectCollection using the `AssetDatabase.FindAssets` instead of the `TypeCache` first
- Added confirmation popup for deleting items from the Collection
- Fixed issue while renaming one asset could be canceled on arrow keys press

## [2.3.3]
## Added
Expand Down
9 changes: 9 additions & 0 deletions Scripts/Editor/CustomEditors/CollectionCustomEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,9 @@ private void BindCollectionItemListItem(VisualElement targetElement, int targetI

private void OnKeyUpOnCollectionListView(KeyUpEvent evt)
{
if (currentRenamingLabel != null)
return;

switch (evt.keyCode)
{
case KeyCode.F2:
Expand Down Expand Up @@ -648,6 +651,12 @@ protected void DeleteItemAtIndex(int selectedIndex)
return;
}

if (!EditorUtility.DisplayDialog($"Delete {scriptableObject.name}",
$"Are you sure you want to delete {scriptableObject.name}?", "Yes", "No"))
{
return;
}

Undo.RecordObject(collection, "Remove Item");

filteredItems.Remove(scriptableObject);
Expand Down
14 changes: 11 additions & 3 deletions Scripts/Runtime/Utils/AssetDatabaseUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,18 @@ public static void CreatePathIfDoesntExist(string targetPath)
public static void RenameAsset(Object targetObject, string newName)
{
#if UNITY_EDITOR
UnityEditor.AssetDatabase.RenameAsset(UnityEditor.AssetDatabase.GetAssetPath(targetObject), newName);
targetObject.name = newName;
string assetPath = UnityEditor.AssetDatabase.GetAssetPath(targetObject);

string guid = UnityEditor.AssetDatabase.AssetPathToGUID(assetPath);
UnityEditor.Undo.SetCurrentGroupName($"Rename Asset from {targetObject.name} to {newName}");
UnityEditor.Undo.RecordObject(targetObject, "Rename Asset");

UnityEditor.AssetDatabase.RenameAsset(assetPath, newName);

UnityEditor.Undo.CollapseUndoOperations(UnityEditor.Undo.GetCurrentGroup());
ObjectUtility.SetDirty(targetObject);
UnityEditor.AssetDatabase.ImportAsset(UnityEditor.AssetDatabase.GUIDToAssetPath(guid));
#endif
}
}
}
}

0 comments on commit 75087cc

Please sign in to comment.