File tree Expand file tree Collapse file tree 2 files changed +22
-5
lines changed
Assets/MackySoft/MackySoft.SerializeReferenceExtensions/Editor Expand file tree Collapse file tree 2 files changed +22
-5
lines changed Original file line number Diff line number Diff line change 28
28
29
29
# Build
30
30
- name : Build .unitypackage
31
- uses : game-ci/unity-builder@v2
31
+ uses : game-ci/unity-builder@v4
32
+ env :
33
+ UNITY_LICENSE : ${{ secrets.UNITY_LICENSE }}
34
+ UNITY_EMAIL : ${{ secrets.UNITY_EMAIL }}
35
+ UNITY_PASSWORD : ${{ secrets.UNITY_PASSWORD }}
32
36
with :
33
- unityVersion : 2020 .3.8f1
37
+ unityVersion : 2021 .3.29f1
34
38
buildMethod : MackySoft.PackageTools.Editor.UnityPackageExporter.Export
35
39
36
40
# Upload
Original file line number Diff line number Diff line change 2
2
using System ;
3
3
using System . Reflection ;
4
4
using UnityEditor ;
5
+ using UnityEngine ;
5
6
6
7
namespace MackySoft . SerializeReferenceExtensions . Editor {
7
8
public static class ManagedReferenceUtility {
8
9
9
10
public static object SetManagedReference ( this SerializedProperty property , Type type ) {
10
- object obj = ( type != null ) ? Activator . CreateInstance ( type ) : null ;
11
- property . managedReferenceValue = obj ;
12
- return obj ;
11
+ object result ;
12
+ if ( property . managedReferenceValue != null )
13
+ {
14
+ // Restore an previous values from json.
15
+ string json = JsonUtility . ToJson ( property . managedReferenceValue ) ;
16
+ result = JsonUtility . FromJson ( json , type ) ;
17
+ }
18
+ else
19
+ {
20
+ result = ( type != null ) ? Activator . CreateInstance ( type ) : null ;
21
+ }
22
+
23
+ property . managedReferenceValue = result ;
24
+ return result ;
25
+
13
26
}
14
27
15
28
public static Type GetType ( string typeName ) {
You can’t perform that action at this time.
0 commit comments