Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Editor/UXML/CollectionCustomEditorTreeAsset.uxml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<uie:ObjectField label="Generated Scripts Folde" type="UnityEditor.DefaultAsset, UnityEditor.CoreModule" allow-scene-objects="false" name="generated-scripts-parent-folder" tooltip="Specifies the target folder for generating the static file access. If left null, the file will be generated in the same location as the original file." class="unity-base-field__aligned" />
<ui:TextField picking-mode="Ignore" label="Static Filename" value="filler text" name="static-filename-textfield" is-delayed="true" class="unity-base-field__aligned" />
<ui:TextField picking-mode="Ignore" label="Namespace" value="filler text" name="namespace-textfield" is-delayed="true" class="unity-base-field__aligned" />
<ui:Toggle label="Generate Addressables Loading Methods" name="write-addressables-load-toggle" class="unity-base-field__aligned" />
<ui:Toggle label="Generate Addressables Methods" name="write-addressables-load-toggle" tooltip="When enabled the static file file will be generated with the Asset Loading Key and with Loading/Unloading methods." class="unity-base-field__aligned" />
</ui:VisualElement>
<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;">
<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;" />
Expand Down
29 changes: 12 additions & 17 deletions Scripts/Editor/Core/CollectionSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,10 @@ public CollectionSettings(ScriptableObjectCollection targetCollection)
else
StaticFilename = $"{targetCollection.GetType().Name}".FirstToUpper();



WriteAsPartialClass = canBePartial;
UseBaseClassForItems = false;
EnforceIndirectAccess = false;
Save();
}

public bool ShouldWriteAddressableLoadingMethods()
Expand All @@ -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)
Expand All @@ -109,7 +105,6 @@ public void SetStaticFilename(string targetNewName)

StaticFilename = targetNewName;
Save();

}

public void SetNamespace(string targetNamespace)
Expand Down
2 changes: 1 addition & 1 deletion Scripts/Editor/Core/SOCSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
}
3 changes: 3 additions & 0 deletions Scripts/Editor/CustomEditors/CollectionCustomEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 10 additions & 11 deletions Scripts/Runtime/Core/ScriptableObjectCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -77,17 +87,6 @@ public void CopyTo(List<ScriptableObject> 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)
{
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down