From 78302ac1d8fc9c6e3e82643d088831e30b84a8b8 Mon Sep 17 00:00:00 2001 From: Harald Csaszar Date: Mon, 27 Mar 2023 17:42:32 +0200 Subject: [PATCH 1/2] [unity] Corrected behaviour of SkeletonGraphic edit reference rect when entering/exiting play mode. See #1640. --- .../Editor/Components/SkeletonGraphicInspector.cs | 11 +++++++++++ .../Runtime/spine-unity/Components/SkeletonGraphic.cs | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/SkeletonGraphicInspector.cs b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/SkeletonGraphicInspector.cs index aaf574906..edf82f4d0 100644 --- a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/SkeletonGraphicInspector.cs +++ b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/SkeletonGraphicInspector.cs @@ -141,9 +141,20 @@ namespace Spine.Unity.Editor { separatorSlotNames = so.FindProperty("separatorSlotNames"); separatorSlotNames.isExpanded = true; + + EditorApplication.playModeStateChanged += OnPlaymodeChanged; } void OnDisable () { + EditorApplication.playModeStateChanged -= OnPlaymodeChanged; + DisableEditReferenceRectMode(); + } + + void OnPlaymodeChanged (PlayModeStateChange mode) { + DisableEditReferenceRectMode(); + } + + void DisableEditReferenceRectMode () { foreach (UnityEngine.Object c in targets) { SkeletonGraphic component = (SkeletonGraphic)c; component.EditReferenceRect = false; diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonGraphic.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonGraphic.cs index e4df73edc..ca174711e 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonGraphic.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonGraphic.cs @@ -321,8 +321,8 @@ namespace Spine.Unity { public virtual void Update () { #if UNITY_EDITOR + UpdateReferenceRectSizes(); if (!Application.isPlaying) { - UpdateReferenceRectSizes(); Update(0f); return; } From 80b2246d6268a7243ed83ba7b89bcd4c631fae16 Mon Sep 17 00:00:00 2001 From: Harald Csaszar Date: Mon, 27 Mar 2023 17:55:53 +0200 Subject: [PATCH 2/2] [unity] Fixed compile error on Unity 2017.1 of last commit. See #1640. --- .../Components/SkeletonGraphicInspector.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/SkeletonGraphicInspector.cs b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/SkeletonGraphicInspector.cs index edf82f4d0..85a8f1af5 100644 --- a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/SkeletonGraphicInspector.cs +++ b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/SkeletonGraphicInspector.cs @@ -35,6 +35,10 @@ #define HAS_CULL_TRANSPARENT_MESH #endif +#if UNITY_2017_2_OR_NEWER +#define NEWPLAYMODECALLBACKS +#endif + using System.Reflection; using UnityEditor; using UnityEngine; @@ -142,15 +146,27 @@ namespace Spine.Unity.Editor { separatorSlotNames = so.FindProperty("separatorSlotNames"); separatorSlotNames.isExpanded = true; +#if NEWPLAYMODECALLBACKS EditorApplication.playModeStateChanged += OnPlaymodeChanged; +#else + EditorApplication.playmodeStateChanged += OnPlaymodeChanged; +#endif } void OnDisable () { +#if NEWPLAYMODECALLBACKS EditorApplication.playModeStateChanged -= OnPlaymodeChanged; +#else + EditorApplication.playmodeStateChanged -= OnPlaymodeChanged; +#endif DisableEditReferenceRectMode(); } +#if NEWPLAYMODECALLBACKS void OnPlaymodeChanged (PlayModeStateChange mode) { +#else + void OnPlaymodeChanged () { +#endif DisableEditReferenceRectMode(); }