From f60b321618f20abf2876823c5fe4a5bfaa9f63b8 Mon Sep 17 00:00:00 2001 From: davidg-unity <32170748+davidg-unity@users.noreply.github.com> Date: Fri, 23 Mar 2018 15:16:00 -0400 Subject: [PATCH] [issue #30] Fixed an issue where removing a clip would cause nullreference issues --- .../SimpleAnimationPlayable.cs | 10 +--------- .../SimpleAnimationPlayable_States.cs | 2 +- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/Assets/SimpleAnimationComponent/SimpleAnimationPlayable.cs b/Assets/SimpleAnimationComponent/SimpleAnimationPlayable.cs index 2b599c8f..b287e740 100644 --- a/Assets/SimpleAnimationComponent/SimpleAnimationPlayable.cs +++ b/Assets/SimpleAnimationComponent/SimpleAnimationPlayable.cs @@ -331,15 +331,7 @@ private bool IsClonePlaying(StateInfo state) public int GetClipCount() { - int count=0; - for (int i = 0; i < m_States.Count; i++) - { - if (m_States[i] != null) - { - count++; - } - } - return count; + return m_States.Count; } private void SetupLerp(StateInfo state, float targetWeight, float time) diff --git a/Assets/SimpleAnimationComponent/SimpleAnimationPlayable_States.cs b/Assets/SimpleAnimationComponent/SimpleAnimationPlayable_States.cs index 876496b4..ae94927c 100644 --- a/Assets/SimpleAnimationComponent/SimpleAnimationPlayable_States.cs +++ b/Assets/SimpleAnimationComponent/SimpleAnimationPlayable_States.cs @@ -365,7 +365,7 @@ public void RemoveAtIndex(int index) { removed.playable.GetGraph().DestroyPlayable(removed.playable); } - m_Count = m_States.Count; + m_Count--; } public bool RemoveClip(AnimationClip clip)