Skip to content

Commit 5796f89

Browse files
committed
Replace Activator.CreateInstance(type) with FormatterServices.GetUninitializedObject(type) when creating reference instances
1 parent ebf2971 commit 5796f89

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Assets/Editor Toolbox/Editor/Drawers/Toolbox/PropertySelf/ReferencePickerAttributeDrawer.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#if UNITY_2019_3_OR_NEWER
22
using System;
3+
using System.Runtime.Serialization;
34

45
using UnityEditor;
56
using UnityEngine;
@@ -74,7 +75,7 @@ private void CreateTypeProperty(Rect position, SerializedProperty property, Type
7475

7576
private void UpdateTypeProperty(SerializedProperty property, Type referenceType)
7677
{
77-
var obj = referenceType != null ? Activator.CreateInstance(referenceType) : null;
78+
var obj = referenceType != null ? FormatterServices.GetUninitializedObject(referenceType) : null;
7879
property.serializedObject.Update();
7980
property.managedReferenceValue = obj;
8081
property.serializedObject.ApplyModifiedProperties();

0 commit comments

Comments
 (0)