Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#if UNITY_2019_3_OR_NEWER
// NOTE: managedReferenceValue getter is available only in Unity 2021.3 or later.
#if UNITY_2021_3_OR_NEWER
using UnityEditor;
using UnityEngine;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,19 @@ namespace MackySoft.SerializeReferenceExtensions.Editor {
public static class ManagedReferenceUtility {

public static object SetManagedReference (this SerializedProperty property,Type type) {
object result;
object result = null;

#if UNITY_2021_3_OR_NEWER
// NOTE: managedReferenceValue getter is available only in Unity 2021.3 or later.
if (property.managedReferenceValue != null)
{
// Restore an previous values from json.
string json = JsonUtility.ToJson(property.managedReferenceValue);
result = JsonUtility.FromJson(json, type);
}
else
#endif

if (result == null)
{
result = (type != null) ? Activator.CreateInstance(type) : null;
}
Expand Down