Skip to content

Commit cc77a82

Browse files
committed
fix: Fixed type being null when SerializeReference is used on a field next to a serializable class that uses TypeReference
1 parent 68bf0d0 commit cc77a82

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Runtime/TypeReference.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,14 @@ public TypeReference(Type type, string guid = null, bool suppressLogs = false)
9898
/// </exception>
9999
public Type Type
100100
{
101-
get => _type;
101+
get
102+
{
103+
// Workaround for a bug in Unity where a SerializeReference field affects the deserialization of a SerializeField field placed nearby.
104+
if (_type == null && IsNotEmpty(_typeNameAndAssembly))
105+
_type = TryGetTypeFromSerializedFields();
106+
107+
return _type;
108+
}
102109
set
103110
{
104111
MakeSureTypeHasName(value);

0 commit comments

Comments
 (0)