Skip to content

Commit b08644a

Browse files
committed
Minor refactor changes
1 parent ea4512e commit b08644a

5 files changed

Lines changed: 39 additions & 16 deletions

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
using System.Runtime.CompilerServices;
2+
3+
[assembly: InternalsVisibleTo("Toolbox.Editor.Tests")]

Assets/Editor Toolbox/Editor/AssemblyInfo.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Editor Toolbox/Editor/ToolboxDrawerModule.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,20 @@ internal static void InitializeModule()
1919
}
2020

2121

22-
private readonly static Type decoratorDrawerBase = typeof(ToolboxDecoratorDrawer<>);
23-
private readonly static Type conditionDrawerBase = typeof(ToolboxConditionDrawer<>);
24-
private readonly static Type selfPropertyDrawerBase = typeof(ToolboxSelfPropertyDrawer<>);
25-
private readonly static Type listPropertyDrawerBase = typeof(ToolboxListPropertyDrawer<>);
22+
private static readonly Type decoratorDrawerBase = typeof(ToolboxDecoratorDrawer<>);
23+
private static readonly Type conditionDrawerBase = typeof(ToolboxConditionDrawer<>);
24+
private static readonly Type selfPropertyDrawerBase = typeof(ToolboxSelfPropertyDrawer<>);
25+
private static readonly Type listPropertyDrawerBase = typeof(ToolboxListPropertyDrawer<>);
2626

27-
private readonly static Dictionary<Type, ToolboxDecoratorDrawerBase> decoratorDrawers = new Dictionary<Type, ToolboxDecoratorDrawerBase>();
28-
private readonly static Dictionary<Type, ToolboxConditionDrawerBase> conditionDrawers = new Dictionary<Type, ToolboxConditionDrawerBase>();
29-
private readonly static Dictionary<Type, ToolboxPropertyDrawerBase> selfPropertyDrawers = new Dictionary<Type, ToolboxPropertyDrawerBase>();
30-
private readonly static Dictionary<Type, ToolboxPropertyDrawerBase> listPropertyDrawers = new Dictionary<Type, ToolboxPropertyDrawerBase>();
27+
private static readonly Dictionary<Type, ToolboxDecoratorDrawerBase> decoratorDrawers = new Dictionary<Type, ToolboxDecoratorDrawerBase>();
28+
private static readonly Dictionary<Type, ToolboxConditionDrawerBase> conditionDrawers = new Dictionary<Type, ToolboxConditionDrawerBase>();
29+
private static readonly Dictionary<Type, ToolboxPropertyDrawerBase> selfPropertyDrawers = new Dictionary<Type, ToolboxPropertyDrawerBase>();
30+
private static readonly Dictionary<Type, ToolboxPropertyDrawerBase> listPropertyDrawers = new Dictionary<Type, ToolboxPropertyDrawerBase>();
3131

3232
/// <summary>
3333
/// Collection of specific drawers mapped to selected (picked) object types.
3434
/// </summary>
35-
private readonly static Dictionary<Type, ToolboxTargetTypeDrawer> targetTypeDrawers = new Dictionary<Type, ToolboxTargetTypeDrawer>();
35+
private static readonly Dictionary<Type, ToolboxTargetTypeDrawer> targetTypeDrawers = new Dictionary<Type, ToolboxTargetTypeDrawer>();
3636

3737
/// <summary>
3838
/// Collection of currently cached handlers mapped to a unique property key.

Assets/Editor Toolbox/Editor/Utilities/PropertyUtility.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
using UnityEditor;
88
using Object = UnityEngine.Object;
99

10-
[assembly: InternalsVisibleTo("Toolbox.Editor.Tests")]
11-
1210
namespace Toolbox.Editor
1311
{
1412
public static partial class PropertyUtility
@@ -27,7 +25,9 @@ internal static bool HasModifedProperties(this SerializedProperty property)
2725
internal static string GetPropertyHashKey(this SerializedProperty property)
2826
{
2927
var hash = property.serializedObject.GetHashCode();
30-
return string.Format("{0}.{1}", hash, property.propertyPath);
28+
return property.propertyType != SerializedPropertyType.ManagedReference
29+
? $"{hash}.{property.propertyPath}"
30+
: $"{hash}.{property.propertyPath}.{property.managedReferenceFieldTypename}";
3131
}
3232

3333
/// <summary>
@@ -36,7 +36,9 @@ internal static string GetPropertyHashKey(this SerializedProperty property)
3636
internal static string GetPropertyTypeKey(this SerializedProperty property)
3737
{
3838
var type = property.serializedObject.targetObject.GetType();
39-
return string.Format("{0}.{1}", type, property.propertyPath);
39+
return property.propertyType != SerializedPropertyType.ManagedReference
40+
? $"{type}.{property.propertyPath}"
41+
: $"{type}.{property.propertyPath}.{property.managedReferenceFieldTypename}";
4042
}
4143

4244
/// <summary>

Assets/Examples/Scenes/SampleScene.unity

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -584,14 +584,21 @@ MonoBehaviour:
584584
references:
585585
version: 1
586586
00000000:
587-
type: {class: SampleBehaviour6/Struct, ns: , asm: Assembly-CSharp}
587+
type: {class: SampleBehaviour6/ClassWithInterface1, ns: , asm: Assembly-CSharp}
588588
data:
589-
var1: 1
590-
var2: 1
589+
go: {fileID: 977748987}
590+
var1:
591+
id: 2
591592
00000001:
592593
type: {class: SampleBehaviour6/ClassWithInterface2, ns: , asm: Assembly-CSharp}
593594
data:
594595
var1: 0
596+
mat: {fileID: 2100000, guid: 7404c70251f9d0045a4aabaa49d83963, type: 2}
597+
00000002:
598+
type: {class: SampleBehaviour6/Struct, ns: , asm: Assembly-CSharp}
599+
data:
600+
var1: 1
601+
var2: 0
595602
--- !u!4 &752799893
596603
Transform:
597604
m_ObjectHideFlags: 2

0 commit comments

Comments
 (0)