diff --git a/CHANGELOG.MD b/CHANGELOG.MD index c5ce2b9..740b10d 100644 --- a/CHANGELOG.MD +++ b/CHANGELOG.MD @@ -6,6 +6,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [2.3.2] +## Added +- Added tooltip for the Generate Addressables Method toggle + +## Changed +- Changed the Save method for the SOCSettings to be less expensive +- Fixed issue when the Addressables Settings haven't been created yet +- Organized Methods/Properties on the Collection +- Bumped minimum supported version to 2022.2 + ## [2.3.1] ### Added - Added Addressables support again, now you if addressables is available on your project and the collection is set to non auto loaded, and the collection is set to use addressables, will write some helper code on the static file to load the collectiom from the addressables. @@ -552,6 +562,7 @@ public bool IsValidConsumable(Consumable consumable) ### Added - First initial working version +[2.3.2]: https://github.com/badawe/ScriptableObjectCollection/releases/tag/v2.3.2 [2.3.1]: https://github.com/badawe/ScriptableObjectCollection/releases/tag/v2.3.1 [2.3.0]: https://github.com/badawe/ScriptableObjectCollection/releases/tag/v2.3.0 [2.2.4]: https://github.com/badawe/ScriptableObjectCollection/releases/tag/v2.2.4 diff --git a/Editor/UXML/CollectionCustomEditorTreeAsset.uxml b/Editor/UXML/CollectionCustomEditorTreeAsset.uxml index c53ad4f..aee0f3e 100644 --- a/Editor/UXML/CollectionCustomEditorTreeAsset.uxml +++ b/Editor/UXML/CollectionCustomEditorTreeAsset.uxml @@ -23,7 +23,7 @@ - + diff --git a/Scripts/Editor/Core/CollectionSettings.cs b/Scripts/Editor/Core/CollectionSettings.cs index 557c64c..eef3c01 100644 --- a/Scripts/Editor/Core/CollectionSettings.cs +++ b/Scripts/Editor/Core/CollectionSettings.cs @@ -52,11 +52,10 @@ public CollectionSettings(ScriptableObjectCollection targetCollection) else StaticFilename = $"{targetCollection.GetType().Name}".FirstToUpper(); - - WriteAsPartialClass = canBePartial; UseBaseClassForItems = false; EnforceIndirectAccess = false; + Save(); } public bool ShouldWriteAddressableLoadingMethods() @@ -67,30 +66,27 @@ public bool ShouldWriteAddressableLoadingMethods() return WriteAddressableLoadingMethods; } - public void SetWriteAddressableLoadingMethods(bool evtNewValue) - { - if (WriteAddressableLoadingMethods == evtNewValue) - return; - - WriteAddressableLoadingMethods = evtNewValue; - Save(); - } - public void SetImporter(AssetImporter targetImporter) { importer = targetImporter; } - public void Save(bool forceSave = false) + public void Save() { if (importer == null) return; importer.userData = EditorJsonUtility.ToJson(this); - if (forceSave) - { - importer.SaveAndReimport(); - } + AssetDatabase.WriteImportSettingsIfDirty(importer.assetPath); + } + + public void SetWriteAddressableLoadingMethods(bool shouldWriteAddressablesMethods) + { + if (WriteAddressableLoadingMethods == shouldWriteAddressablesMethods) + return; + + WriteAddressableLoadingMethods = shouldWriteAddressablesMethods; + Save(); } public void SetEnforceIndirectAccess(bool enforceIndirectAccess) @@ -109,7 +105,6 @@ public void SetStaticFilename(string targetNewName) StaticFilename = targetNewName; Save(); - } public void SetNamespace(string targetNamespace) diff --git a/Scripts/Editor/Core/SOCSettings.cs b/Scripts/Editor/Core/SOCSettings.cs index 91c9bcd..5af907e 100644 --- a/Scripts/Editor/Core/SOCSettings.cs +++ b/Scripts/Editor/Core/SOCSettings.cs @@ -299,7 +299,7 @@ public bool GetWriteAddressableLoadingMethods(ScriptableObjectCollection collect public void SaveCollectionSettings(ScriptableObjectCollection collection, bool forceSave = false) { CollectionSettings settings = GetOrCreateCollectionSettings(collection); - settings.Save(forceSave); + settings.Save(); } } } diff --git a/Scripts/Editor/CustomEditors/CollectionCustomEditor.cs b/Scripts/Editor/CustomEditors/CollectionCustomEditor.cs index f13044a..9c355a8 100644 --- a/Scripts/Editor/CustomEditors/CollectionCustomEditor.cs +++ b/Scripts/Editor/CustomEditors/CollectionCustomEditor.cs @@ -580,6 +580,9 @@ private bool IsAddressableAsset(ScriptableObject target) #if ADDRESSABLES_ENABLED string assetPath = AssetDatabase.GetAssetPath(target); AddressableAssetSettings settings = AddressableAssetSettingsDefaultObject.Settings; + if (settings == null) + return false; + AddressableAssetEntry entry = settings.FindAssetEntry(AssetDatabase.AssetPathToGUID(assetPath)); return entry != null; #else diff --git a/Scripts/Runtime/Core/ScriptableObjectCollection.cs b/Scripts/Runtime/Core/ScriptableObjectCollection.cs index a1046c1..6e0efcc 100644 --- a/Scripts/Runtime/Core/ScriptableObjectCollection.cs +++ b/Scripts/Runtime/Core/ScriptableObjectCollection.cs @@ -35,6 +35,16 @@ public LongGuid GUID private bool automaticallyLoaded = true; public bool AutomaticallyLoaded => automaticallyLoaded; + public int Count => items.Count; + + public object SyncRoot => throw new NotSupportedException(); + public bool IsSynchronized => throw new NotSupportedException(); + + public bool IsFixedSize => false; + public bool IsReadOnly => false; + + public virtual bool ShouldProtectItemOrder => false; + public ScriptableObject this[int index] { get => items[index]; @@ -77,17 +87,6 @@ public void CopyTo(List list) list.Add(e); } } - - public int Count => items.Count; - - public object SyncRoot => throw new NotSupportedException(); - public bool IsSynchronized => throw new NotSupportedException(); - - public bool IsFixedSize => false; - public bool IsReadOnly => false; - - public virtual bool ShouldProtectItemOrder => false; - public int Add(object value) { diff --git a/package.json b/package.json index 4f5f4f5..424d602 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { "name": "com.brunomikoski.scriptableobjectcollection", "displayName": "Scriptable Object Collection", - "version": "2.3.1", - "unity": "2021.2", + "version": "2.3.2", + "unity": "2022.2", "description": "A library to help improve the usability of Unity3D Scriptable Objects by grouping them into a collection and exposing them by code or nice inspectors!", "keywords": [ "scriptable object",