Skip to content

Commit

Permalink
Replace Activator.CreateInstance(type) with FormatterServices.GetUnin…
Browse files Browse the repository at this point in the history
…itializedObject(type) when creating reference instances
  • Loading branch information
arimger committed Jan 16, 2024
1 parent ebf2971 commit 5796f89
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#if UNITY_2019_3_OR_NEWER
using System;
using System.Runtime.Serialization;

using UnityEditor;
using UnityEngine;
Expand Down Expand Up @@ -74,7 +75,7 @@ private void CreateTypeProperty(Rect position, SerializedProperty property, Type

private void UpdateTypeProperty(SerializedProperty property, Type referenceType)
{
var obj = referenceType != null ? Activator.CreateInstance(referenceType) : null;
var obj = referenceType != null ? FormatterServices.GetUninitializedObject(referenceType) : null;
property.serializedObject.Update();
property.managedReferenceValue = obj;
property.serializedObject.ApplyModifiedProperties();
Expand Down

0 comments on commit 5796f89

Please sign in to comment.