Skip to content

Commit

Permalink
Merge pull request #31 from brunomikoski/feature/fix-issue-and-format…
Browse files Browse the repository at this point in the history
…tation-

Feature/fix issue and formattation
  • Loading branch information
brunomikoski committed Sep 2, 2020
2 parents 1b156a8 + c7f7ca1 commit 3f9e888
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 43 deletions.
39 changes: 16 additions & 23 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,20 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.2.5]
## Changed
- Fixed issue with the read only lists not refreshing properly on Inspector calls on PlayMode.

## [1.2.4]
## Changed
- Fixed issue where the collection view was not properly refreshing
- Fixed general warnings on the project
- Fixed double type usage on the ResourceScriptableObject
- Renamed the `Values` to `Collection` on the static generated file, it makes more sense to the new Custom Static Class access

## Added
## Added
- Added a new Custom Static File to be able to generate static access files between different assemblies
- Added warning system to help displaying issues


## [1.2.3]
## Changed
- Not serializing editor fields
Expand All @@ -26,8 +27,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Changed
- Fixed issue with the settings menu been displayed wrong
- Fixed an issue while converting numbers to literal numbers would not deal properly with initial special characters

## Added
## Added
- Added system to be able to Add/Remove items from the collection at runtime (Like loading new items from addressables)
- Added runtime / editor time fix to deal with dynamicly changed collections

Expand All @@ -38,10 +38,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [1.2.0]
## Changed
- Fixed issue with the wizzard that was not generating the target Scriptable Object

## Added
- New type of indirect access to collectable items, this allows you use the regular editor reference, but without storing the reference, so without creating a relationship between the items, and can be lazy loaded when is needed, like addressables references for isntance.
- Also added an option on the wizzard to automatically create the IndirectReference for every collectable item
- New type of indirect access to collectable items, this allows you use the regular editor reference, but without storing the reference, so without creating a relationship between the items, and can be lazy loaded when is needed, like addressables references for isntance.
- Also added an option on the wizzard to automatically create the IndirectReference for every collectable item

## [1.1.9]
## Changed
Expand All @@ -57,7 +56,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Default namespace on settings
- Stored the last scripts folder as cache for the wizzard
- Validation of null items on the Registry

## Changed
- Changed to the static file use the Colllectable Type again
- Values on the static files now its just values not `CollectableType+Values`
Expand All @@ -76,8 +74,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed Create Collection context menu using the selected folder as target for both scrips and scriptable objects
- Fixed some warnings
- Fixed weird pair next name issue

## Added
## Added
- You can now set specific overwrite static files location on the `CollectionSettings` file
- Settings are now displayed on the Collection itself rather than on the registry

Expand All @@ -97,20 +94,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- Changed the Settings file to be the main place where data is stored, not using EditorPrefs anymore
- Added all the namespaces for individual assets as diretives on top of static generated file

## Fixed
- Fixed issue with the Add New Item missing the DelayCall on the Collection Editor Window
- Fixed issue with the Add New Item missing the DelayCall on the Collection Editor Window

## [1.1.1]
### Added
- Added the `[CreateAssetMenu]` to the Collection automatic generated file

### Changed
- The Static file uses the Collection name instead of the collectable type, so you can have multiple collections of the same type and unique access to that specific collection
- Fixed asset creation menu name to use `ScriptableObject` instead of `Scriptable Object`

## Fixed
- Editor Group issues when adding new items throwing error
- The Static file uses the Collection name instead of the collectable type, so you can have multiple collections of the same type and unique access to that specific collection
- Fixed asset creation menu name to use `ScriptableObject` instead of `Scriptable Object`
- Editor Group issues when adding new items throwing error

## [1.1.0]
### Added
Expand All @@ -120,8 +112,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- New type of script static script generation for Non automatically loaded collections
- Added new Custom Editor for the registry where you can define witch collection are auto loaded, and the static generation type
- PreProcess that removes the non automatically loaded collections before build

### Changed
### Changed
- General bug fixes and optimizations
- Fixed issue with the dropdown on property drawer

Expand All @@ -136,8 +127,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- First initial working version

## [Unreleased]
- Add a setup wizzard for first time settings creation
- Proper setup for automatic creation of necessary collections

[1.2.5]: https://github.com/badawe/ScriptableObjectCollection/releases/tag/v1.2.5
[1.2.4]: https://github.com/badawe/ScriptableObjectCollection/releases/tag/v1.2.4
[1.2.3]: https://github.com/badawe/ScriptableObjectCollection/releases/tag/v1.2.3
[1.2.2]: https://github.com/badawe/ScriptableObjectCollection/releases/tag/v1.2.2
[1.2.1]: https://github.com/badawe/ScriptableObjectCollection/releases/tag/v1.2.1
Expand Down
48 changes: 29 additions & 19 deletions Scripts/Runtime/ScriptableObjectCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,23 @@ public string GUID
[SerializeField]
protected List<CollectableScriptableObject> items = new List<CollectableScriptableObject>();

[NonSerialized]
private bool isReadyOnlyListDirty = true;

private IReadOnlyList<CollectableScriptableObject> readOnlyList = new List<CollectableScriptableObject>();
public IReadOnlyList<CollectableScriptableObject> Items
{
get
{
if (isReadyListDirty)
if (isReadyOnlyListDirty)
{
readOnlyList = items.AsReadOnly();
isReadyListDirty = false;

isReadyOnlyListDirty = false;
}
return readOnlyList;
}
}

[NonSerialized]
protected bool isReadyListDirty = true;

private void SyncGUID()
{
Expand Down Expand Up @@ -123,7 +123,7 @@ public bool Add(CollectableScriptableObject item)

item.SetCollection(this);
ObjectUtility.SetDirty(this);
isReadyListDirty = true;
isReadyOnlyListDirty = true;
return true;
}

Expand Down Expand Up @@ -158,7 +158,7 @@ public CollectableScriptableObject AddNew(Type collectionType)
UnityEditor.AssetDatabase.CreateAsset(item, newFileName);
UnityEditor.AssetDatabase.SaveAssets();
UnityEditor.AssetDatabase.Refresh();
isReadyListDirty = true;
isReadyOnlyListDirty = true;
return item;
}
#endif
Expand Down Expand Up @@ -186,15 +186,15 @@ public Type GetGenericEnumType()
public virtual void Sort()
{
items.Sort();
isReadyListDirty = true;
isReadyOnlyListDirty = true;
ObjectUtility.SetDirty(this);
}

public void Clear()
{
items.Clear();
ObjectUtility.SetDirty(this);
isReadyListDirty = true;
isReadyOnlyListDirty = true;
}

public bool Contains(object value)
Expand Down Expand Up @@ -222,7 +222,7 @@ public void Insert(int index, CollectableScriptableObject item)
items.Insert(index, item);
item.SetCollection(this);
ObjectUtility.SetDirty(this);
isReadyListDirty = true;
isReadyOnlyListDirty = true;
}

public void Insert(int index, object value)
Expand All @@ -234,7 +234,7 @@ public bool Remove(CollectableScriptableObject item)
{
bool result = items.Remove(item);
ObjectUtility.SetDirty(this);
isReadyListDirty = true;
isReadyOnlyListDirty = true;

return result;
}
Expand All @@ -248,7 +248,7 @@ public void RemoveAt(int index)
{
items.RemoveAt(index);
ObjectUtility.SetDirty(this);
isReadyListDirty = true;
isReadyOnlyListDirty = true;
}

object IList.this[int index]
Expand All @@ -266,7 +266,7 @@ public void Swap(int targetIndex, int newIndex)
items[targetIndex] = items[newIndex];
items[newIndex] = temp;
ObjectUtility.SetDirty(this);
isReadyListDirty = true;
isReadyOnlyListDirty = true;
}

public void ClearBadItems()
Expand All @@ -277,7 +277,7 @@ public void ClearBadItems()
items.RemoveAt(i);
}
ObjectUtility.SetDirty(this);
isReadyListDirty = true;
isReadyOnlyListDirty = true;
}

public void ValidateGUID()
Expand Down Expand Up @@ -337,7 +337,7 @@ public void RefreshCollection()

items = items.Where(o => o != null).Distinct().ToList();
ObjectUtility.SetDirty(this);
isReadyListDirty = true;
isReadyOnlyListDirty = true;
#endif
}

Expand Down Expand Up @@ -372,15 +372,19 @@ internal void PrepareForEditorMode()
public class ScriptableObjectCollection<ObjectType> : ScriptableObjectCollection, IList<ObjectType>
where ObjectType : CollectableScriptableObject
{

[NonSerialized]
private bool isReadyOnlyListDirty = true;

private IReadOnlyList<ObjectType> readOnlyList = new List<ObjectType>();
public new IReadOnlyList<ObjectType> Items
{
get
{
if (isReadyListDirty)
if (isReadyOnlyListDirty)
{
readOnlyList = items.Cast<ObjectType>().ToList().AsReadOnly();
isReadyListDirty = false;
isReadyOnlyListDirty = false;
}
return readOnlyList;
}
Expand All @@ -407,11 +411,14 @@ public ObjectType GetCollectableByGUID(string targetGUID)
public void Add(ObjectType item)
{
base.Add(item);
isReadyOnlyListDirty = true;
}

public ObjectType Add(Type itemType = null)
{
return base.Add(itemType) as ObjectType;
ObjectType collectableScriptableObject = base.Add(itemType) as ObjectType;
isReadyOnlyListDirty = true;
return collectableScriptableObject;
}

public bool Contains(ObjectType item)
Expand All @@ -432,11 +439,14 @@ public int IndexOf(ObjectType item)
public void Insert(int index, ObjectType item)
{
base.Insert(index, item);
isReadyOnlyListDirty = true;
}

public bool Remove(ObjectType item)
{
return base.Remove(item);
bool remove = base.Remove(item);
isReadyOnlyListDirty = true;
return remove;
}

IEnumerator<ObjectType> IEnumerable<ObjectType>.GetEnumerator()
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "com.brunomikoski.scriptableobjectcollection",
"displayName": "Scriptable Object Collection",
"version": "1.2.4",
"version": "1.2.5",
"unity": "2018.4",
"description": "Scriptable Object Collection",
"keywords": [
Expand Down

0 comments on commit 3f9e888

Please sign in to comment.