Reset() public méthode

public Reset ( ) : void
Résultat void
Exemple #1
0
    /// <summary>
    /// Like PlayAnim, but plays the animation in reverse.
    /// See <see cref="PlayAnim"/>.
    /// </summary>
    /// <param name="anim">Reference to the animation to play in reverse.</param>
    public void PlayAnimInReverse(UVAnimation anim)
    {
#if UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_4_7 || UNITY_4_8 || UNITY_4_9
        if (deleted || !gameObject.activeInHierarchy)
#else
        if (deleted || !gameObject.active)
#endif
        { return; }

        curAnim = anim;
        curAnim.Reset();
        curAnim.PlayInReverse();

        // Ensure the framerate is not 0 so we don't
        // divide by zero:
        if (anim.framerate != 0.0f)
        {
            timeBetweenAnimFrames = 1f / anim.framerate;
        }
        else
        {
            timeBetweenAnimFrames = 1f;             // Just some dummy value since it won't be used
        }

        timeSinceLastFrame = timeBetweenAnimFrames;

        // Only add to the animated list if
        // the animation has more than 1 frame:
        if ((anim.GetFrameCount() > 1 || anim.onAnimEnd != UVAnimation.ANIM_END_ACTION.Do_Nothing) && anim.framerate != 0.0f)
        {
            StepAnim(0);
            // Start coroutine
            if (!animating)
            {
                //animating = true;
                AddToAnimatedList();
                //StartCoroutine(AnimationPump());
            }
        }
        else
        {
            // Make sure we are no longer in the animation pump:
            PauseAnim();

            // Since this is a single-frame anim,
            // call our delegate before setting
            // the frame so that our behavior is
            // consistent with multi-frame anims:
            if (animCompleteDelegate != null)
            {
                animCompleteDelegate(this);
            }

            StepAnim(0);
        }
    }
Exemple #2
0
    // Starts playing the specified animation
    // (Note: this doesn't resume from a pause,
    // it completely restarts the animation. To
    // unpause, use UnpauseAnim):
    public void PlayAnim(UVAnimation anim)
    {
        // Cancel any previously playing anim:
        CancelInvoke("StepAnim");

        curAnim = anim;
        curAnim.Reset();

        StepAnim();
        InvokeRepeating("StepAnim", 1f / anim.framerate, 1f / anim.framerate);
    }
Exemple #3
0
    /// <summary>
    /// Starts playing the specified animation
    /// Note: this doesn't resume from a pause,
    /// it completely restarts the animation. To
    /// unpause, use <see cref="UnpauseAnim"/>.
    /// </summary>
    /// <param name="anim">A reference to the animation to play.</param>
    /// <param name="frame">The zero-based index of the frame at which to start playing.</param>
    public void PlayAnim(UVAnimation anim, int frame)
    {
        if (deleted || !gameObject.active)
        {
            return;
        }

        curAnim      = anim;
        curAnimIndex = curAnim.index;
        curAnim.Reset();
        curAnim.SetCurrentFrame(frame - 1);             // curFrame inside UVAnimation will be incremented before it is used, so anticipate this by decrementing by 1

        // Ensure the framerate is not 0 so we don't
        // divide by zero:
        if (anim.framerate != 0.0f)
        {
            timeBetweenAnimFrames = 1f / anim.framerate;
        }
        else
        {
            timeBetweenAnimFrames = 1f;             // Just some dummy value since it won't be used
        }

        timeSinceLastFrame = timeBetweenAnimFrames;

        // Only add to the animated list if
        // the animation has more than 1 frame
        // or the framerate is non-zero:
        if ((anim.GetFrameCount() > 1 || anim.onAnimEnd != UVAnimation.ANIM_END_ACTION.Do_Nothing) && anim.framerate != 0.0f)
        {
            StepAnim(0);
            // Start coroutine
            if (!animating)
            {
                //animating = true;
                AddToAnimatedList();
                //StartCoroutine(AnimationPump());
            }
        }
        else
        {
            // Since this is a single-frame anim,
            // call our delegate before setting
            // the frame so that our behavior is
            // consistent with multi-frame anims:
            if (animCompleteDelegate != null)
            {
                animCompleteDelegate(this);
            }

            StepAnim(0);
        }
    }
Exemple #4
0
    /// <summary>
    /// Like PlayAnim, but plays the animation in reverse.
    /// See <see cref="PlayAnim"/>.
    /// </summary>
    /// <param name="anim">Reference to the animation to play in reverse.</param>
    /// <param name="frame">The zero-based index of the frame at which to start playing.</param>
    public void PlayAnimInReverse(UVAnimation anim, int frame)
    {
#if UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_4_7 || UNITY_4_8 || UNITY_4_9
        if (deleted || !gameObject.activeInHierarchy)
#else
        if (deleted || !gameObject.active)
#endif
        { return; }
        if (!m_started)
        {
            Start();
        }

        curAnim = anim;
        curAnim.Reset();
        curAnim.PlayInReverse();
        curAnim.SetCurrentFrame(frame + 1);             // curFrame inside UVAnimation will be decremented before it is used, so anticipate this by decrementing by 1

        // Ensure the framerate is not 0 so we don't
        // divide by zero:
        anim.framerate = Mathf.Max(0.0001f, anim.framerate);

        timeBetweenAnimFrames = 1f / anim.framerate;
        timeSinceLastFrame    = timeBetweenAnimFrames;

        // Only add to the animated list if
        // the animation has more than 1 frame:
        if (anim.GetFrameCount() > 1)
        {
            StepAnim(0);
            // Start coroutine
            if (!animating)
            {
                //animating = true;
                AddToAnimatedList();
                //StartCoroutine(AnimationPump());
            }
        }
        else
        {
            // Since this is a single-frame anim,
            // call our delegate before setting
            // the frame so that our behavior is
            // consistent with multi-frame anims:
            if (animCompleteDelegate != null)
            {
                animCompleteDelegate(this);
            }

            StepAnim(0);
        }
    }
Exemple #5
0
    // Starts playing the specified animation
    // (Note: this doesn't resume from a pause,
    // it completely restarts the animation. To
    // unpause, use UnpauseAnim):
    public void PlayAnim(UVAnimation anim)
    {
        // First stop any currently playing animation:
        m_manager.StopAnimation(this);

        curAnim = anim;
        curAnim.Reset();
        timeBetweenAnimFrames = 1f / anim.framerate;
        timeSinceLastFrame    = timeBetweenAnimFrames;
        StepAnim(0);

        m_manager.AnimateSprite(this);
    }
Exemple #6
0
    /// <summary>
    /// Stops the current animation from playing
    /// and resets it to the beginning for playing
    /// again.  The sprite then reverts to the static
    /// image.
    /// </summary>
    public override void StopAnim()
    {
        // Stop coroutine
        //animating = false;
        RemoveFromAnimatedList();

        //StopAllCoroutines();

        // Reset the animation:
        if (curAnim != null)
        {
            curAnim.Reset();
        }

        // Revert to our static appearance:
        RevertToStatic();
    }
Exemple #7
0
    /// <summary>
    /// Like PlayAnim, but plays the animation in reverse.
    /// See <see cref="PlayAnim"/>.
    /// </summary>
    /// <param name="anim">Reference to the animation to play in reverse.</param>
    public void PlayAnimInReverse(UVAnimation anim)
    {
        curAnim = anim;
        curAnim.Reset();
        curAnim.PlayInReverse();

        // Ensure the framerate is not 0 so we don't
        // divide by zero:
        anim.framerate = Mathf.Max(0.0001f, anim.framerate);

        timeBetweenAnimFrames = 1f / anim.framerate;
        timeSinceLastFrame    = timeBetweenAnimFrames;

        // Only add to the animated list if
        // the animation has more than 1 frame:
        if (anim.GetFrameCount() > 1)
        {
            StepAnim(0);
            // Start coroutine
            if (!animating)
            {
                //animating = true;
                AddToAnimatedList();
                //StartCoroutine(AnimationPump());
            }
        }
        else
        {
            // Since this is a single-frame anim,
            // call our delegate before setting
            // the frame so that our behavior is
            // consistent with multi-frame anims:
            if (animCompleteDelegate != null)
            {
                animCompleteDelegate(this);
            }

            StepAnim(0);
        }
    }
	/// <summary>
	/// Like PlayAnim, but plays the animation in reverse.
	/// See <see cref="PlayAnim"/>.
	/// </summary>
	/// <param name="anim">Reference to the animation to play in reverse.</param>
	/// <param name="frame">The zero-based index of the frame at which to start playing.</param>
	public void PlayAnimInReverse(UVAnimation anim, int frame)
	{
#if UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_4_7 || UNITY_4_8 || UNITY_4_9
		if (deleted || !gameObject.activeInHierarchy)
#else
		if (deleted || !gameObject.active)
#endif
			return;
		if (!m_started)
			Start();

		curAnim = anim;
		curAnim.Reset();
		curAnim.PlayInReverse();
		curAnim.SetCurrentFrame(frame + 1);	// curFrame inside UVAnimation will be decremented before it is used, so anticipate this by decrementing by 1

		// Ensure the framerate is not 0 so we don't
		// divide by zero:
		anim.framerate = Mathf.Max(0.0001f, anim.framerate);

		timeBetweenAnimFrames = 1f / anim.framerate;
		timeSinceLastFrame = timeBetweenAnimFrames;

		// Only add to the animated list if
		// the animation has more than 1 frame:
		if (anim.GetFrameCount() > 1)
		{
			StepAnim(0);
			// Start coroutine
			if (!animating)
			{
				//animating = true;
				AddToAnimatedList();
				//StartCoroutine(AnimationPump());
			}
		}
		else
		{
			// Since this is a single-frame anim,
			// call our delegate before setting
			// the frame so that our behavior is
			// consistent with multi-frame anims:
			if (animCompleteDelegate != null)
				animCompleteDelegate(this);

			StepAnim(0);
		}
	}
	/// <summary>
	/// Like PlayAnim, but plays the animation in reverse.
	/// See <see cref="PlayAnim"/>.
	/// </summary>
	/// <param name="anim">Reference to the animation to play in reverse.</param>
	public void PlayAnimInReverse(UVAnimation anim)
	{
#if UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_4_7 || UNITY_4_8 || UNITY_4_9
		if (deleted || !gameObject.activeInHierarchy)
#else
		if (deleted || !gameObject.active)
#endif
			return;

		curAnim = anim;
		curAnim.Reset();
		curAnim.PlayInReverse();

		// Ensure the framerate is not 0 so we don't
		// divide by zero:
		if (anim.framerate != 0.0f)
		{
			timeBetweenAnimFrames = 1f / anim.framerate;
		}
		else
		{
			timeBetweenAnimFrames = 1f; // Just some dummy value since it won't be used
		}

		timeSinceLastFrame = timeBetweenAnimFrames;

		// Only add to the animated list if
		// the animation has more than 1 frame:
		if ((anim.GetFrameCount() > 1 || anim.onAnimEnd != UVAnimation.ANIM_END_ACTION.Do_Nothing) && anim.framerate != 0.0f)
		{
			StepAnim(0);
			// Start coroutine
			if (!animating)
			{
				//animating = true;
				AddToAnimatedList();
				//StartCoroutine(AnimationPump());
			}
		}
		else
		{
			// Make sure we are no longer in the animation pump:
			PauseAnim();

			// Since this is a single-frame anim,
			// call our delegate before setting
			// the frame so that our behavior is
			// consistent with multi-frame anims:
			if (animCompleteDelegate != null)
				animCompleteDelegate(this);

			StepAnim(0);
		}
	}
	/// <summary>
	/// Starts playing the specified animation
	/// Note: this doesn't resume from a pause,
	/// it completely restarts the animation. To
	/// unpause, use <see cref="UnpauseAnim"/>.
	/// </summary>
	/// <param name="anim">A reference to the animation to play.</param>
	/// <param name="frame">The zero-based index of the frame at which to start playing.</param>
	public void PlayAnim(UVAnimation anim, int frame)
	{
#if UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_4_7 || UNITY_4_8 || UNITY_4_9
		if (deleted || !gameObject.activeInHierarchy)
#else
		if (deleted || !gameObject.active)
#endif
			return;

		if (!m_started)
			Start();

		curAnim = anim;
		curAnimIndex = curAnim.index;
		curAnim.Reset();
		curAnim.SetCurrentFrame(frame - 1);	// curFrame inside UVAnimation will be incremented before it is used, so anticipate this by decrementing by 1

		// Ensure the framerate is not 0 so we don't
		// divide by zero:
		if (anim.framerate != 0.0f)
		{
			timeBetweenAnimFrames = 1f / anim.framerate;
		}
		else
		{
			timeBetweenAnimFrames = 1f; // Just some dummy value since it won't be used
		}

		timeSinceLastFrame = timeBetweenAnimFrames;

		// Only add to the animated list if
		// the animation has more than 1 frame
		// or the framerate is non-zero:
		if ((anim.GetFrameCount() > 1 || anim.onAnimEnd != UVAnimation.ANIM_END_ACTION.Do_Nothing) && anim.framerate != 0.0f)
		{
			StepAnim(0);
			// Start coroutine
			if (!animating)
			{
				//animating = true;
				AddToAnimatedList();
				//StartCoroutine(AnimationPump());
			}
		}
		else
		{
			// Make sure we are no longer in the animation pump:
			PauseAnim();

			// Since this is a single-frame anim,
			// call our delegate before setting
			// the frame so that our behavior is
			// consistent with multi-frame anims:
			if (animCompleteDelegate != null)
			{
				// See if we need to delay calling
				// our delegate to be consistent
				// with our framerate:
				if (anim.framerate != 0)
				{
					Invoke("CallAnimCompleteDelegate", 1f / anim.framerate);
				}
				else
					animCompleteDelegate(this);
			}

			StepAnim(0);
		}
	}
Exemple #11
0
    // Like PlayAnim but plays in reverse:
    public void PlayAnimInReverse(UVAnimation anim)
    {
        // First stop any currently playing animation:
        m_manager.StopAnimation(this);

        curAnim = anim;
        curAnim.Reset();
        curAnim.PlayInReverse();
        timeBetweenAnimFrames = 1f / anim.framerate;
        timeSinceLastFrame = timeBetweenAnimFrames;
        StepAnim(0);

        m_manager.AnimateSprite(this);
    }
Exemple #12
0
    /// <summary>
    /// Like PlayAnim, but plays the animation in reverse.
    /// See <see cref="PlayAnim"/>.
    /// </summary>
    /// <param name="anim">Reference to the animation to play in reverse.</param>
    public void PlayAnimInReverse(UVAnimation anim)
    {
        curAnim = anim;
        curAnim.Reset();
        curAnim.PlayInReverse();

        // Ensure the framerate is not 0 so we don't
        // divide by zero:
        anim.framerate = Mathf.Max(0.0001f, anim.framerate);

        timeBetweenAnimFrames = 1f / anim.framerate;
        timeSinceLastFrame = timeBetweenAnimFrames;

        // Only add to the animated list if
        // the animation has more than 1 frame:
        if (anim.GetFrameCount() > 1)
        {
            StepAnim(0);
            // Start coroutine
            if (!animating)
            {
                //animating = true;
                AddToAnimatedList();
                //StartCoroutine(AnimationPump());
            }
        }
        else
        {
            // Since this is a single-frame anim,
            // call our delegate before setting
            // the frame so that our behavior is
            // consistent with multi-frame anims:
            if (animCompleteDelegate != null)
                animCompleteDelegate(this);

            StepAnim(0);
        }
    }
Exemple #13
0
    /// <summary>
    /// Starts playing the specified animation
    /// Note: this doesn't resume from a pause,
    /// it completely restarts the animation. To
    /// unpause, use <see cref="UnpauseAnim"/>.
    /// </summary>
    /// <param name="anim">A reference to the animation to play.</param>
    /// <param name="frame">The zero-based index of the frame at which to start playing.</param>
    public void PlayAnim(UVAnimation anim, int frame)
    {
        if (deleted || !gameObject.active)
            return;

        curAnim = anim;
        curAnimIndex = curAnim.index;
        curAnim.Reset();
        curAnim.SetCurrentFrame(frame - 1);	// curFrame inside UVAnimation will be incremented before it is used, so anticipate this by decrementing by 1

        // Ensure the framerate is not 0 so we don't
        // divide by zero:
        if(anim.framerate != 0.0f)
        {
            timeBetweenAnimFrames = 1f / anim.framerate;
        }
        else
        {
            timeBetweenAnimFrames = 1f; // Just some dummy value since it won't be used
        }

        timeSinceLastFrame = timeBetweenAnimFrames;

        // Only add to the animated list if
        // the animation has more than 1 frame
        // or the framerate is non-zero:
        if ( (anim.GetFrameCount() > 1 || anim.onAnimEnd != UVAnimation.ANIM_END_ACTION.Do_Nothing) && anim.framerate != 0.0f)
        {
            StepAnim(0);
            // Start coroutine
            if (!animating)
            {
                //animating = true;
                AddToAnimatedList();
                //StartCoroutine(AnimationPump());
            }
        }
        else
        {
            // Since this is a single-frame anim,
            // call our delegate before setting
            // the frame so that our behavior is
            // consistent with multi-frame anims:
            if (animCompleteDelegate != null)
                animCompleteDelegate(this);

            StepAnim(0);
        }
    }
Exemple #14
0
    /// <summary>
    /// Starts playing the specified animation
    /// Note: this doesn't resume from a pause,
    /// it completely restarts the animation. To
    /// unpause, use <see cref="UnpauseAnim"/>.
    /// </summary>
    /// <param name="anim">A reference to the animation to play.</param>
    /// <param name="frame">The zero-based index of the frame at which to start playing.</param>
    public void PlayAnim(UVAnimation anim, int frame)
    {
#if UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_4_7 || UNITY_4_8 || UNITY_4_9
        if (deleted || !gameObject.activeInHierarchy)
#else
        if (deleted || !gameObject.active)
#endif
        { return; }

        if (!m_started)
        {
            Start();
        }

        curAnim      = anim;
        curAnimIndex = curAnim.index;
        curAnim.Reset();
        curAnim.SetCurrentFrame(frame - 1);             // curFrame inside UVAnimation will be incremented before it is used, so anticipate this by decrementing by 1

        // Ensure the framerate is not 0 so we don't
        // divide by zero:
        if (anim.framerate != 0.0f)
        {
            timeBetweenAnimFrames = 1f / anim.framerate;
        }
        else
        {
            timeBetweenAnimFrames = 1f;             // Just some dummy value since it won't be used
        }

        timeSinceLastFrame = timeBetweenAnimFrames;

        // Only add to the animated list if
        // the animation has more than 1 frame
        // or the framerate is non-zero:
        if ((anim.GetFrameCount() > 1 || anim.onAnimEnd != UVAnimation.ANIM_END_ACTION.Do_Nothing) && anim.framerate != 0.0f)
        {
            StepAnim(0);
            // Start coroutine
            if (!animating)
            {
                //animating = true;
                AddToAnimatedList();
                //StartCoroutine(AnimationPump());
            }
        }
        else
        {
            // Make sure we are no longer in the animation pump:
            PauseAnim();

            // Since this is a single-frame anim,
            // call our delegate before setting
            // the frame so that our behavior is
            // consistent with multi-frame anims:
            if (animCompleteDelegate != null)
            {
                // See if we need to delay calling
                // our delegate to be consistent
                // with our framerate:
                if (anim.framerate != 0)
                {
                    Invoke("CallAnimCompleteDelegate", 1f / anim.framerate);
                }
                else
                {
                    animCompleteDelegate(this);
                }
            }

            StepAnim(0);
        }
    }