Skip to content

Commit f522e0f

Browse files
authored
Merge pull request #47 from mackysoft/fix/compatibility-less-than-2021-3
Fix compatibility for less than Unity 2021.3
2 parents afb3089 + d061f74 commit f522e0f

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

Assets/MackySoft/MackySoft.SerializeReferenceExtensions/Editor/CopyAndPasteProperty.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
#if UNITY_2019_3_OR_NEWER
1+
// NOTE: managedReferenceValue getter is available only in Unity 2021.3 or later.
2+
#if UNITY_2021_3_OR_NEWER
23
using UnityEditor;
34
using UnityEngine;
45

Assets/MackySoft/MackySoft.SerializeReferenceExtensions/Editor/ManagedReferenceUtility.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,19 @@ namespace MackySoft.SerializeReferenceExtensions.Editor {
88
public static class ManagedReferenceUtility {
99

1010
public static object SetManagedReference (this SerializedProperty property,Type type) {
11-
object result;
11+
object result = null;
12+
13+
#if UNITY_2021_3_OR_NEWER
14+
// NOTE: managedReferenceValue getter is available only in Unity 2021.3 or later.
1215
if (property.managedReferenceValue != null)
1316
{
1417
// Restore an previous values from json.
1518
string json = JsonUtility.ToJson(property.managedReferenceValue);
1619
result = JsonUtility.FromJson(json, type);
1720
}
18-
else
21+
#endif
22+
23+
if (result == null)
1924
{
2025
result = (type != null) ? Activator.CreateInstance(type) : null;
2126
}

0 commit comments

Comments
 (0)