From 425bb8fe7f72cb7871f3ac1586ee4a974d6b72f4 Mon Sep 17 00:00:00 2001 From: pharan Date: Wed, 24 Feb 2016 18:11:38 +0800 Subject: [PATCH] YieldInstruction warnings. --- .../WaitForSpineAnimationComplete.cs | 11 +++- .../YieldInstructions/WaitForSpineEvent.cs | 55 ++++++++++++++----- 2 files changed, 50 insertions(+), 16 deletions(-) diff --git a/spine-unity/Assets/spine-unity/Modules/YieldInstructions/WaitForSpineAnimationComplete.cs b/spine-unity/Assets/spine-unity/Modules/YieldInstructions/WaitForSpineAnimationComplete.cs index a2c385bb4..51449ff5f 100644 --- a/spine-unity/Assets/spine-unity/Modules/YieldInstructions/WaitForSpineAnimationComplete.cs +++ b/spine-unity/Assets/spine-unity/Modules/YieldInstructions/WaitForSpineAnimationComplete.cs @@ -29,7 +29,11 @@ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -//using UnityEngine; +#if (UNITY_5_0 || UNITY_5_1 || UNITY_5_2 || UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_4_7) +#define PREUNITY_5_3 +#endif + +using UnityEngine; using System.Collections; using Spine; @@ -42,6 +46,10 @@ namespace Spine { bool m_WasFired = false; public WaitForSpineAnimationComplete (Spine.TrackEntry trackEntry) { + #if PREUNITY_5_3 + Debug.LogWarning("Unity 5.3 or later is required for Spine Unity custom yield instructions to function correctly."); + #endif + SafeSubscribe(trackEntry); } @@ -52,6 +60,7 @@ namespace Spine { void SafeSubscribe (Spine.TrackEntry trackEntry) { if (trackEntry == null) { // Break immediately if trackEntry is null. + Debug.LogWarning("TrackEntry was null. Coroutine will continue immediately."); m_WasFired = true; } else { // Function normally. diff --git a/spine-unity/Assets/spine-unity/Modules/YieldInstructions/WaitForSpineEvent.cs b/spine-unity/Assets/spine-unity/Modules/YieldInstructions/WaitForSpineEvent.cs index 28280b5c7..8e69f8727 100644 --- a/spine-unity/Assets/spine-unity/Modules/YieldInstructions/WaitForSpineEvent.cs +++ b/spine-unity/Assets/spine-unity/Modules/YieldInstructions/WaitForSpineEvent.cs @@ -29,7 +29,11 @@ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -//using UnityEngine; +#if (UNITY_5_0 || UNITY_5_1 || UNITY_5_2 || UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_4_7) +#define PREUNITY_5_3 +#endif + +using UnityEngine; using System.Collections; using Spine; @@ -48,27 +52,48 @@ namespace Spine { #region Constructors void Subscribe (Spine.AnimationState state, Spine.EventData eventDataReference, bool unsubscribe) { - if (state == null || eventDataReference == null) { - m_WasFired = true; - } else { - m_AnimationState = state; - m_TargetEvent = eventDataReference; - state.Event += HandleAnimationStateEvent; + #if PREUNITY_5_3 + Debug.LogWarning("Unity 5.3 or later is required for Spine Unity custom yield instructions to function correctly."); + #endif - m_unsubscribeAfterFiring = unsubscribe; + if (state == null) { + Debug.LogWarning("AnimationState argument was null. Coroutine will continue immediately."); + m_WasFired = true; + return; + } else if (eventDataReference == null) { + Debug.LogWarning("eventDataReference argument was null. Coroutine will continue immediately."); + m_WasFired = true; + return; } + + m_AnimationState = state; + m_TargetEvent = eventDataReference; + state.Event += HandleAnimationStateEvent; + + m_unsubscribeAfterFiring = unsubscribe; + } void SubscribeByName (Spine.AnimationState state, string eventName, bool unsubscribe) { - if (state == null || string.IsNullOrEmpty(eventName)) { - m_WasFired = true; - } else { - m_AnimationState = state; - m_EventName = eventName; - state.Event += HandleAnimationStateEventByName; + #if PREUNITY_5_3 + Debug.LogWarning("Unity 5.3 or later is required for Spine Unity custom yield instructions to function correctly."); + #endif - m_unsubscribeAfterFiring = unsubscribe; + if (state == null) { + Debug.LogWarning("AnimationState argument was null. Coroutine will continue immediately."); + m_WasFired = true; + return; + } else if (string.IsNullOrEmpty(eventName)) { + Debug.LogWarning("eventName argument was null. Coroutine will continue immediately."); + m_WasFired = true; + return; } + + m_AnimationState = state; + m_EventName = eventName; + state.Event += HandleAnimationStateEventByName; + + m_unsubscribeAfterFiring = unsubscribe; } public WaitForSpineEvent (Spine.AnimationState state, Spine.EventData eventDataReference, bool unsubscribeAfterFiring = true) {