Skip to content

Commit 989b9c0

Browse files
committed
add: meta changes
1 parent 45a2586 commit 989b9c0

4 files changed

Lines changed: 71 additions & 57 deletions

File tree

CHANGELOG.MD

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,16 @@ 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).
66

77
## [Unreleased]
8+
9+
## [2.0.8]
10+
### Changed
811
- Fixed a small typo in the package description.
12+
- Since [2.0.3] the collection now uses the Editor for drawing the items on the collection, but this can cause some issues depending of how customized it is inside a ReorderableList, so you now can choose the item to use it or not by toggling the `Use Custom Editor` inside the advanced settings
13+
- Upgraded the `CollectionCustomEditor` to use `BaseEditor`
14+
- Updated `CollectionItemPicker<>` to use `IndirectReference<>` to store the items, since also contains the `LongGuid` reference to the Collection, allowing to work with multiple collections of the same time _(It should automatically upgrade to the new version automatically)_
15+
- Added ability to compare `CollectionItemPicker<>` to a `IList<>` of the same type
16+
- Other small fixes and improvements
17+
918

1019
## [2.0.7]
1120
### Changed
@@ -459,6 +468,7 @@ public bool IsValidConsumable(Consumable consumable)
459468
### Added
460469
- First initial working version
461470

471+
[2.0.8]: https://github.com/badawe/ScriptableObjectCollection/releases/tag/v2.0.8
462472
[2.0.7]: https://github.com/badawe/ScriptableObjectCollection/releases/tag/v2.0.7
463473
[2.0.6]: https://github.com/badawe/ScriptableObjectCollection/releases/tag/v2.0.6
464474
[2.0.5]: https://github.com/badawe/ScriptableObjectCollection/releases/tag/v2.0.5

Scripts/Editor/Utils/CopyCollectionItemUtility.cs

Lines changed: 1 addition & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,8 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Reflection;
4-
using UnityEditor;
1+
using UnityEditor;
52
using UnityEngine;
6-
using Object = UnityEngine.Object;
73

84
namespace BrunoMikoski.ScriptableObjectCollections
95
{
10-
public static class EditorCache
11-
{
12-
private static Dictionary<object, Editor> typeToEditorCache = new();
13-
14-
private static Dictionary<Type, bool> typeToHasCustomEditorCache = new();
15-
16-
public static Editor GetOrCreateEditorForObject(Object targetObject)
17-
{
18-
if (typeToEditorCache.TryGetValue(targetObject, out Editor editor))
19-
return editor;
20-
21-
editor = Editor.CreateEditor(targetObject);
22-
typeToEditorCache.Add(targetObject, editor);
23-
return editor;
24-
}
25-
26-
public static bool HasCustomEditor(Object objectReferenceValue)
27-
{
28-
Type objectType = objectReferenceValue.GetType();
29-
if(typeToHasCustomEditorCache.TryGetValue(objectType, out bool hasCustomEditor))
30-
return hasCustomEditor;
31-
32-
TypeCache.TypeCollection customEditors = TypeCache.GetTypesWithAttribute<CustomEditor>();
33-
34-
foreach (var type in customEditors)
35-
{
36-
object[] attributes = type.GetCustomAttributes(typeof(CustomEditor), true);
37-
foreach (var attribute in attributes)
38-
{
39-
Type attributeType = attribute.GetType();
40-
41-
// Access the `m_InspectedType` field using reflection
42-
FieldInfo fieldInfo = attributeType.GetField("m_InspectedType", BindingFlags.NonPublic | BindingFlags.Instance);
43-
44-
if (fieldInfo != null)
45-
{
46-
Type inspectedType = fieldInfo.GetValue(attribute) as Type;
47-
48-
if (inspectedType == objectType || inspectedType.IsSubclassOf(objectType))
49-
{
50-
typeToHasCustomEditorCache.Add(objectType, true);
51-
return true;
52-
}
53-
}
54-
}
55-
}
56-
typeToHasCustomEditorCache.Add(objectType, false);
57-
return false;
58-
}
59-
}
60-
616
public static class CopyCollectionItemUtility
627
{
638
private static ScriptableObject source;
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Reflection;
4+
using UnityEditor;
5+
using Object = UnityEngine.Object;
6+
7+
namespace BrunoMikoski.ScriptableObjectCollections
8+
{
9+
public static class EditorCache
10+
{
11+
private static Dictionary<object, Editor> typeToEditorCache = new();
12+
13+
private static Dictionary<Type, bool> typeToHasCustomEditorCache = new();
14+
15+
public static Editor GetOrCreateEditorForObject(Object targetObject)
16+
{
17+
if (typeToEditorCache.TryGetValue(targetObject, out Editor editor))
18+
return editor;
19+
20+
editor = Editor.CreateEditor(targetObject);
21+
typeToEditorCache.Add(targetObject, editor);
22+
return editor;
23+
}
24+
25+
public static bool HasCustomEditor(Object objectReferenceValue)
26+
{
27+
Type objectType = objectReferenceValue.GetType();
28+
if(typeToHasCustomEditorCache.TryGetValue(objectType, out bool hasCustomEditor))
29+
return hasCustomEditor;
30+
31+
TypeCache.TypeCollection customEditors = TypeCache.GetTypesWithAttribute<CustomEditor>();
32+
33+
foreach (var type in customEditors)
34+
{
35+
object[] attributes = type.GetCustomAttributes(typeof(CustomEditor), true);
36+
foreach (var attribute in attributes)
37+
{
38+
Type attributeType = attribute.GetType();
39+
40+
// Access the `m_InspectedType` field using reflection
41+
FieldInfo fieldInfo = attributeType.GetField("m_InspectedType", BindingFlags.NonPublic | BindingFlags.Instance);
42+
43+
if (fieldInfo != null)
44+
{
45+
Type inspectedType = fieldInfo.GetValue(attribute) as Type;
46+
47+
if (inspectedType == objectType || inspectedType.IsSubclassOf(objectType))
48+
{
49+
typeToHasCustomEditorCache.Add(objectType, true);
50+
return true;
51+
}
52+
}
53+
}
54+
}
55+
typeToHasCustomEditorCache.Add(objectType, false);
56+
return false;
57+
}
58+
}
59+
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "com.brunomikoski.scriptableobjectcollection",
33
"displayName": "Scriptable Object Collection",
4-
"version": "2.0.7",
4+
"version": "2.0.8",
55
"unity": "2021.2",
66
"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!",
77
"keywords": [

0 commit comments

Comments
 (0)