From ecf5418a253d9f2689b6c68817fe95aebdec7d32 Mon Sep 17 00:00:00 2001 From: Harald Csaszar Date: Thu, 25 Aug 2022 15:45:19 +0200 Subject: [PATCH] [unity] Fixed Exception at SetIconForObject with Unity 2021.2. Closes #2141. --- .../Editor/Components/SkeletonUtilityInspector.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/SkeletonUtilityInspector.cs b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/SkeletonUtilityInspector.cs index 4394e7412..f36a6a764 100644 --- a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/SkeletonUtilityInspector.cs +++ b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/SkeletonUtilityInspector.cs @@ -31,6 +31,10 @@ #define NEW_PREFAB_SYSTEM #endif +#if UNITY_2021_2_OR_NEWER +#define PUBLIC_SET_ICON_FOR_OBJECT +#endif + using System.Reflection; using UnityEditor; using UnityEngine; @@ -145,11 +149,14 @@ namespace Spine.Unity.Editor { icon = Icons.constraintNib; break; } - +#if PUBLIC_SET_ICON_FOR_OBJECT + EditorGUIUtility.SetIconForObject(boneComponent.gameObject, icon); +#else typeof(EditorGUIUtility).InvokeMember("SetIconForObject", BindingFlags.InvokeMethod | BindingFlags.Static | BindingFlags.NonPublic, null, null, new object[2] { boneComponent.gameObject, icon }); +#endif } static void AttachIconsToChildren (Transform root) {