|
1 | 1 | using System.Collections;
|
2 | 2 | using System.Collections.Generic;
|
| 3 | +using System.Reflection; |
3 | 4 | using UnityEngine;
|
4 | 5 | using UnityEditor;
|
5 | 6 | using System.Linq;
|
@@ -889,8 +890,6 @@ public HashSet<GameObject> ImplementUpdates(FbxPrefab prefabInstance)
|
889 | 890 | {
|
890 | 891 | Log("{0}: performing updates", prefabInstance.name);
|
891 | 892 |
|
892 |
| - int[] unityVersion = null; |
893 |
| - |
894 | 893 | var updatedNodes = new HashSet<GameObject>();
|
895 | 894 |
|
896 | 895 | // Gather up all the nodes in the prefab so we can look up
|
@@ -1019,21 +1018,15 @@ public HashSet<GameObject> ImplementUpdates(FbxPrefab prefabInstance)
|
1019 | 1018 | rectTransform.localRotation = tempTransform.localRotation;
|
1020 | 1019 | rectTransform.localPosition = tempTransform.localPosition;
|
1021 | 1020 | rectTransform.localScale = tempTransform.localScale;
|
1022 |
| - #region force update of rect transform 2017.3 or newer |
1023 |
| - if (unityVersion == null) { |
1024 |
| - unityVersion = new int [2]; |
1025 | 1021 |
|
1026 |
| - var versionParts = Application.unityVersion.Split ('.'); |
1027 |
| - |
1028 |
| - unityVersion [0] = int.Parse (versionParts [0]); |
1029 |
| - unityVersion [1] = int.Parse (versionParts [1]); |
1030 |
| - } |
1031 |
| - Debug.Assert (unityVersion.Length > 1); |
1032 |
| - |
1033 |
| - // force RectTransform to update (2017.3 or newer) |
1034 |
| - if (unityVersion [0] > 2017 || unityVersion [0] == 2017 && unityVersion [1] >= 3) |
1035 |
| - rectTransform.ForceUpdateRectTransforms (); |
1036 |
| - |
| 1022 | + #region force update of rect transform 2017.3 or newer |
| 1023 | + // using reflection so we can continue to compile against versions 2017.1 |
| 1024 | + // Retrieve the method you are looking for |
| 1025 | + System.Reflection.MethodInfo methodInfo = |
| 1026 | + rectTransform.GetType().GetMethod("ForceUpdateRectTransforms"); |
| 1027 | + // Invoke the method on the instance |
| 1028 | + if (methodInfo!=null) |
| 1029 | + methodInfo.Invoke(rectTransform, null); |
1037 | 1030 | #endregion
|
1038 | 1031 | }
|
1039 | 1032 | finally
|
|
0 commit comments