File tree Expand file tree Collapse file tree 2 files changed +9
-3
lines changed
Assets/MackySoft/MackySoft.SerializeReferenceExtensions/Editor Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change 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
23using UnityEditor ;
34using UnityEngine ;
45
Original file line number Diff line number Diff 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 }
You can’t perform that action at this time.
0 commit comments