예제 #1
0
    private IEnumerator PlayLoopedAnim(string animation, SFXRenderer renderer, SFXRendererCallback callback)
    {
        renderer.animator.Play(animation, -1, 0);
        yield return(new WaitForEndOfFrame());

        while (true)
        {
            float time = renderer.animator.GetCurrentAnimatorStateInfo(0).length;
            yield return(new WaitForSeconds(time));

            callback(renderer);
        }
    }
예제 #2
0
    private void PlayLoopingAnimation(SFXRenderer sfx, string anim)
    {
        if (sfx.currentAction != null)
        {
            StopCoroutine(sfx.currentAction);
        }

        SFXRendererCallback callback = delegate(SFXRenderer sfxR) {};

        sfx.spriteRenderer.enabled = true;
        sfx.animator.enabled       = true;

        sfx.currentAction =
            StartCoroutine(
                PlayLoopedAnim(anim, sfx, callback));
    }