diff --git a/.github/workflows/package.yaml b/.github/workflows/package.yaml index f0238d2..5284801 100644 --- a/.github/workflows/package.yaml +++ b/.github/workflows/package.yaml @@ -28,9 +28,13 @@ jobs: # Build - name: Build .unitypackage - uses: game-ci/unity-builder@v2 + uses: game-ci/unity-builder@v4 + env: + UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }} + UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }} + UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }} with: - unityVersion: 2020.3.8f1 + unityVersion: 2021.3.29f1 buildMethod: MackySoft.PackageTools.Editor.UnityPackageExporter.Export # Upload diff --git a/Assets/MackySoft/MackySoft.SerializeReferenceExtensions/Editor/ManagedReferenceUtility.cs b/Assets/MackySoft/MackySoft.SerializeReferenceExtensions/Editor/ManagedReferenceUtility.cs index bec2c47..5cc7223 100644 --- a/Assets/MackySoft/MackySoft.SerializeReferenceExtensions/Editor/ManagedReferenceUtility.cs +++ b/Assets/MackySoft/MackySoft.SerializeReferenceExtensions/Editor/ManagedReferenceUtility.cs @@ -2,14 +2,27 @@ using System; using System.Reflection; using UnityEditor; +using UnityEngine; namespace MackySoft.SerializeReferenceExtensions.Editor { public static class ManagedReferenceUtility { public static object SetManagedReference (this SerializedProperty property,Type type) { - object obj = (type != null) ? Activator.CreateInstance(type) : null; - property.managedReferenceValue = obj; - return obj; + object result; + if (property.managedReferenceValue != null) + { + // Restore an previous values from json. + string json = JsonUtility.ToJson(property.managedReferenceValue); + result = JsonUtility.FromJson(json, type); + } + else + { + result = (type != null) ? Activator.CreateInstance(type) : null; + } + + property.managedReferenceValue = result; + return result; + } public static Type GetType (string typeName) {