Skip to content

Commit 3f8e9dd

Browse files
authored
Merge pull request #171 from brunomikoski/feature/more-fixes
Feature/more fixes
2 parents 9d8da55 + f7ad40e commit 3f8e9dd

File tree

4 files changed

+16
-21
lines changed

4 files changed

+16
-21
lines changed

CHANGELOG.MD

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ All notable changes to this project will be documented in this file.
33

44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6+
[Unreleased]
7+
## Changed
8+
- Fixed issue when creating multiple items without renaming it would cause a null reference.
9+
- Removed Synchronize Assets button from the Collection Editor, this is already happening multiple times
10+
- Renamed Generator button to Run Generator instead of Generate Items since was misleading
611

712
## [2.4.0] - 24/05/2025
813
## Changed
@@ -712,4 +717,4 @@ public bool IsValidConsumable(Consumable consumable)
712717
[1.1.1]: https://github.com/badawe/ScriptableObjectCollection/releases/tag/v1.1.1
713718
[1.1.0]: https://github.com/badawe/ScriptableObjectCollection/releases/tag/v1.1.0
714719
[1.0.1]: https://github.com/badawe/ScriptableObjectCollection/releases/tag/v1.0.1
715-
[1.0.0]: https://github.com/badawe/ScriptableObjectCollection/releases/tag/v1.0.0
720+
[1.0.0]: https://github.com/badawe/ScriptableObjectCollection/releases/tag/v1.0.0

Editor/UXML/CollectionCustomEditorTreeAsset.uxml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@
2727
</ui:VisualElement>
2828
<ui:VisualElement style="flex-grow: 1; flex-direction: row; height: 26px; border-top-left-radius: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; border-bottom-left-radius: 0;">
2929
<ui:Button text="Generate Static File" parse-escape-sequences="true" display-tooltip-when-elided="true" tooltip="Uses Code Generation to generate the Static File to access collection items by code." name="generate-static-file-button" style="flex-grow: 1; padding-right: 0; padding-left: -2px; margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; padding-top: 0; padding-bottom: 0; border-bottom-right-radius: 0; border-bottom-left-radius: 4px; border-top-left-radius: 0; border-top-right-radius: 0;" />
30-
<ui:Button text="Generate Items" parse-escape-sequences="true" display-tooltip-when-elided="true" tooltip="Uses Code Generation to generate the Static File to access collection items by code." name="generate-auto-items" style="flex-grow: 1; margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0; border-top-left-radius: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; border-bottom-left-radius: 0;" />
31-
<ui:Button text="Synchronize Assets" parse-escape-sequences="true" display-tooltip-when-elided="true" tooltip="Check for invalid references and reload found items into the collection" name="synchronize-items-button" style="flex-grow: 1; margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; padding-top: 0; padding-right: 2px; padding-bottom: 0; padding-left: 0; border-top-left-radius: 0; border-top-right-radius: 0; border-bottom-right-radius: 4px; border-bottom-left-radius: 0;" />
30+
<ui:Button text="Run Generator" parse-escape-sequences="true" display-tooltip-when-elided="true" tooltip="Generate Items based on the current Generator Implementation" name="generate-auto-items" style="flex-grow: 1; margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0; border-top-left-radius: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; border-bottom-left-radius: 0;" />
3231
</ui:VisualElement>
3332
</ui:Instance>
3433
<ui:Instance template="GroupBoxVisualElement" name="GroupBoxVisualElement">

Scripts/Editor/CustomEditors/CollectionCustomEditor.cs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,6 @@ public override VisualElement CreateInspectorGUI()
154154
removeSelectedItemsButton.RegisterCallback<MouseUpEvent>(OnClickRemoveSelectedItems);
155155
removeSelectedItemsButton.SetEnabled(DisplayRemoveButton);
156156

157-
Button synchronizeAssetsButton = root.Q<Button>("synchronize-items-button");
158-
synchronizeAssetsButton.clickable.activators.Clear();
159-
synchronizeAssetsButton.RegisterCallback<MouseUpEvent>(OnClickToSynchronizeAssets);
160-
161157
generateStaticFileButton = root.Q<Button>("generate-static-file-button");
162158
generateStaticFileButton.clickable.activators.Clear();
163159
generateStaticFileButton.RegisterCallback<MouseUpEvent>(OnClickGenerateStaticFile);
@@ -424,12 +420,6 @@ private void OnNamespaceTextFieldChanged(ChangeEvent<string> evt)
424420
SOCSettings.Instance.SetNamespaceForCollection(collection, trimmed);
425421
}
426422

427-
private void OnClickToSynchronizeAssets(MouseUpEvent evt)
428-
{
429-
collection.RefreshCollection();
430-
ReloadFilteredItems();
431-
}
432-
433423
private void OnClickGenerateItems(MouseUpEvent evt)
434424
{
435425
CollectionGenerators.RunGenerator(generatorType, collection);
@@ -1095,4 +1085,4 @@ private static void OnPostprocessAllAssets(string[] importedAssets, string[] del
10951085
}
10961086
}
10971087
}
1098-
}
1088+
}

Scripts/Runtime/Core/ScriptableObjectCollection.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -138,19 +138,20 @@ public ScriptableObject AddNew(Type itemType, string assetName = "")
138138
itemName = $"{itemType.Name}";
139139
}
140140

141-
newItem.name = AssetDatabase.GenerateUniqueAssetPath(itemName);
141+
string uniqueAssetPath = AssetDatabase.GenerateUniqueAssetPath(Path.Combine(parentFolderPath, itemName + ".asset"));
142+
string uniqueName = Path.GetFileNameWithoutExtension(uniqueAssetPath);
143+
144+
newItem.name = uniqueName;
142145

143-
if(itemName.IsReservedKeyword())
146+
if (itemName.IsReservedKeyword())
144147
Debug.LogError($"{itemName} is a reserved keyword name, will cause issues with code generation, please rename it");
145148

146-
string newFileName = Path.Combine(parentFolderPath, newItem.name + ".asset");
147-
148149
ISOCItem socItem = newItem as ISOCItem;
149150
socItem.GenerateNewGUID();
150151

151152
this.Add(newItem);
152153

153-
AssetDatabase.CreateAsset(newItem, newFileName);
154+
AssetDatabase.CreateAsset(newItem, uniqueAssetPath);
154155
ObjectUtility.SetDirty(this);
155156

156157
SerializedObject serializedObject = new SerializedObject(this);
@@ -392,8 +393,8 @@ public void RefreshCollection()
392393
if (itemsFromOtherCollections.Any())
393394
{
394395
int result = EditorUtility.DisplayDialogComplex("Items from another collections",
395-
$"The following items {string.Join(",", itemsFromOtherCollections.Select(o => o.name).ToArray())} belong to other collections, should I move to the appropriated folder?",
396-
"Move to the assigned collection", $"Assign it to this collection ", "Do nothing");
396+
$"The following items {string.Join(",", itemsFromOtherCollections.Select(o => o.name).ToArray())} belong to other collection, what you want to do?",
397+
"Move to the assigned collection", $"Assign it the parent collection ", "Do nothing");
397398

398399
if (result == 0)
399400
{

0 commit comments

Comments
 (0)