public void PlayAnimation(string _name) { if (m_AllAnimations.ContainsKey(_name)) { // // if (m_CurrentPlaing == m_AllAnimations [_name]) { // //same animation // return; // } //HideAllAnimations (); m_AllAnimations [_name].gameObject.SetActive(true); m_AllAnimations [_name].Play(); if (m_CurrentPlaying != null && m_CurrentPlaying != m_AllAnimations [_name]) { //stop previuse, but if playing same, not stop m_CurrentPlaying.Stop(true); } m_CurrentPlaying = m_AllAnimations [_name]; } else { Debug.LogError("SimpleSpriteAnimator : PlayAnimation : Anim name = \" " + _name + "\" is not exist in animator \"" + transform.name + "\". Check childs of this object \"" + transform.name + "\" to exist GameObject as \"" + _name + "\" "); } }
public void PlayAnimation(string _name, bool freeze = false) { if (m_AllAnimations.ContainsKey(_name)) { var targetAnim = m_AllAnimations[_name]; if (m_CurrentPlaing == targetAnim && targetAnim.m_IsPaused == freeze) { //same animation return; } //HideAllAnimations (); targetAnim.gameObject.SetActive(true); if (freeze) { targetAnim.Pause(); } else { targetAnim.Play(); } if (m_CurrentPlaing != null && m_CurrentPlaing != m_AllAnimations [_name]) { //stop previuse, but if playing same, not stop m_CurrentPlaing.Stop(true); } m_CurrentPlaing = m_AllAnimations [_name]; } else { Debug.LogError("SimpleSpriteAnimator : PlayAnimation : Anim name = \" " + _name + "\" is not exist in animator \"" + transform.name + "\". Check childs of this object \"" + transform.name + "\" to exist GameObject as \"" + _name + "\" "); } }