Skip to content

Commit 908efaa

Browse files
committed
refactor: Made _suppressLogs internal in order to use it in ExtEvents
1 parent 92e8d7e commit 908efaa

File tree

3 files changed

+28
-15
lines changed

3 files changed

+28
-15
lines changed

Editor/Util/SerializedTypeReference.cs

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@ internal readonly struct SerializedTypeReference
1414
private readonly SerializedObject _parentObject;
1515
private readonly SerializedProperty _guidProperty;
1616
private readonly SerializedProperty _guidAssignmentFailedProperty;
17+
private readonly SerializedProperty _suppressLogs;
1718

1819
public SerializedTypeReference(SerializedProperty typeReferenceProperty)
1920
{
2021
_parentObject = typeReferenceProperty.serializedObject;
2122
TypeNameProperty = typeReferenceProperty.FindPropertyRelative(nameof(TypeReference._typeNameAndAssembly));
2223
_guidProperty = typeReferenceProperty.FindPropertyRelative(nameof(TypeReference.GUID));
2324
_guidAssignmentFailedProperty = typeReferenceProperty.FindPropertyRelative(nameof(TypeReference.GuidAssignmentFailed));
25+
_suppressLogs = typeReferenceProperty.FindPropertyRelative(nameof(TypeReference._suppressLogs));
2426

2527
FindGuidIfAssignmentFailed();
2628
}
@@ -31,17 +33,39 @@ public string TypeNameAndAssembly
3133
set => SetTypeNameAndAssembly(value);
3234
}
3335

36+
public bool SuppressLogs
37+
{
38+
get => _suppressLogs.boolValue;
39+
set
40+
{
41+
_suppressLogs.boolValue = value;
42+
_parentObject.ApplyModifiedProperties();
43+
}
44+
}
45+
3446
public bool TypeNameHasMultipleDifferentValues => TypeNameProperty.hasMultipleDifferentValues;
3547

3648
private bool GuidAssignmentFailed
3749
{
3850
get => _guidAssignmentFailedProperty.boolValue;
3951
// Used in C# 8
40-
[UsedImplicitly] set => SetGUIDAssignmentFailed(value);
52+
[UsedImplicitly]
53+
set
54+
{
55+
_guidAssignmentFailedProperty.boolValue = value;
56+
_parentObject.ApplyModifiedProperties();
57+
}
4158
}
4259

4360
// Used in C# 8
44-
[UsedImplicitly] private string GUID { set => SetGUID(value); }
61+
[UsedImplicitly] private string GUID
62+
{
63+
set
64+
{
65+
_guidProperty.stringValue = value;
66+
_parentObject.ApplyModifiedProperties();
67+
}
68+
}
4569

4670
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global",
4771
Justification = "The method is used by TypeFieldDrawer in C# 7")]
@@ -59,18 +83,6 @@ public void SetType(Type type)
5983
_parentObject.ApplyModifiedProperties();
6084
}
6185

62-
private void SetGUIDAssignmentFailed(bool value)
63-
{
64-
_guidAssignmentFailedProperty.boolValue = value;
65-
_parentObject.ApplyModifiedProperties();
66-
}
67-
68-
private void SetGUID(string value)
69-
{
70-
_guidProperty.stringValue = value;
71-
_parentObject.ApplyModifiedProperties();
72-
}
73-
7486
private static string GetClassGuidFromTypeName(string typeName)
7587
{
7688
var type = Type.GetType(typeName);

Runtime/AssemblyInfo.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@
44
[assembly: InternalsVisibleTo("TypeReferences.Editor.Tests")]
55
[assembly: InternalsVisibleTo("GenericUnityObjects")]
66
[assembly: InternalsVisibleTo("GenericUnityObjects.Editor")]
7+
[assembly: InternalsVisibleTo("ExtEvents")]
78
[assembly: InternalsVisibleTo("ExtEvents.Editor")]

Runtime/TypeReference.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public partial class TypeReference : ISerializationCallbackReceiver
2222
[SerializeField] internal string _typeNameAndAssembly;
2323
public string TypeNameAndAssembly => _typeNameAndAssembly;
2424

25-
[SerializeField] private bool _suppressLogs;
25+
[SerializeField] internal bool _suppressLogs;
2626

2727
private Type _type;
2828

0 commit comments

Comments
 (0)