/// <summary>
	/// Reset the animation to frame 0 and activate it.
	/// </summary>
	

	public void Play( ANIMMSG _Callback )
	{
		if( mSpriteNames.Count <= 1 || !Application.isPlaying || mLoopTime <= 0f )
		{
			return;
		}
		
		mIndex = 0;
		
		if (mSprite != null && mSpriteNames.Count > 0)
		{
			if( mSprite.enabled )
			{
				mSprite.enabled = false;
			}
			mSprite.spriteName = mSpriteNames[mIndex];
            if (mMakePixelPerfect)
                mSprite.MakePixelPerfect();
            else
                mSprite.SetDimensions(m_SpriteX, m_SpriteY);
		}
		m_OnAnimFinish = _Callback;
		
		if( !mActive )
		{
			mActive = true;
		}
	}
	void Update ()
	{
		
		if( !mActive )
		{
			return;
		}
		
		if(mSprite != null)
		{
			if( !mSprite.enabled )
			{
				mSprite.enabled = true;
			}
		}


        float fDeltaTime = Time.realtimeSinceStartup - m_fLastTime;
        m_fLastTime = Time.realtimeSinceStartup;
        mDelta += fDeltaTime;

		//time between tow frams
		float rate = mLoopTime / mFramCount;

		if (rate < mDelta)
		{				
			//reset timeer when change frame
			mDelta = (rate > 0f) ? mDelta - rate : 0f;
			//finish process
			if (++mIndex >= mFramCount)
			{
				mIndex = 0;
				mActive = loop;
				if( !mActive  && mSprite != null)
				{
					mSprite.enabled = false;
					if( m_OnAnimFinish != null )
					{
						m_OnAnimFinish( this );
						m_OnAnimFinish = null;
					}
                    if (FinishHanelDelegate != null)
                    {
                        FinishHanelDelegate();
                        FinishHanelDelegate = null;
                    }
				}
			}

			if (mActive && mSprite != null)
			{
				mSprite.spriteName = mSpriteNames[mIndex];

                if(mMakePixelPerfect)
                {
                    mSprite.MakePixelPerfect();
                }
                else
                {
                    if (mSaveSizeX.Length > mIndex)
                    {
                        mSprite.SetDimensions(mSaveSizeX[mIndex], mSaveSizeY[mIndex]);
                        mSprite.transform.localScale = new Vector3(mScale, mScale, 1);
                    }
                    else
                    {
                        mSprite.SetDimensions(m_SpriteX, m_SpriteY);
                    }
                }
				
			}
		}
			

		
	}