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
2
3
using UnityEditor ;
3
4
using UnityEngine ;
4
5
Original file line number Diff line number Diff line change @@ -8,14 +8,19 @@ namespace MackySoft.SerializeReferenceExtensions.Editor {
8
8
public static class ManagedReferenceUtility {
9
9
10
10
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.
12
15
if ( property . managedReferenceValue != null )
13
16
{
14
17
// Restore an previous values from json.
15
18
string json = JsonUtility . ToJson ( property . managedReferenceValue ) ;
16
19
result = JsonUtility . FromJson ( json , type ) ;
17
20
}
18
- else
21
+ #endif
22
+
23
+ if ( result == null )
19
24
{
20
25
result = ( type != null ) ? Activator . CreateInstance ( type ) : null ;
21
26
}
You can’t perform that action at this time.
0 commit comments