2020년 2월 27일 목요일

unity animation관련 (플레이 백, startTIme,endTime)

 #region animation관련 (플레이 백, startTIme,endTime)
    public void AnimationPlayAndBack(bool isOn)
    {
        Debug.Log("ani.clip.name:" + animation_Tutorials[0].clip.name);

        if (isOn)
        {
            animation_Tutorials[0][animation_Tutorials[0].clip.name].time = 0;
            animation_Tutorials[0][animation_Tutorials[0].clip.name].speed = 1;
            animation_Tutorials[0].Play(animation_Tutorials[0].clip.name);
        }
        else
        {
            animation_Tutorials[0][animation_Tutorials[0].clip.name].time = animation_Tutorials[0][animation_Tutorials[0].clip.name].length;
            animation_Tutorials[0][animation_Tutorials[0].clip.name].speed = -1;
            animation_Tutorials[0].Play(animation_Tutorials[0].clip.name);
        }
    }

    //public void AnimationPlay(float startTime,float endTime)
    //{
    //    animation_Tutorials[0][animation_Tutorials[0].clip.name].time = startTime;
    //    animation_Tutorials[0][animation_Tutorials[0].clip.name].speed = 1;
    //}

    public void OnAnimationPlayCustomTime(float startTime, float endTime)
    {
        if (cor_CustomAnimation != null)
        {
            StopCoroutine(cor_CustomAnimation);
            cor_CustomAnimation = null;
        }
        cor_CustomAnimation = cor_AnimationPlayCustomTime(startTime, endTime);
        StartCoroutine(cor_CustomAnimation);

        Animation_StartTimes.Enqueue(startTime);
    }

    public void OnAnimationPlayBackCustomTime(float startTime)
    {
        if (cor_CustomAnimationBack != null)
        {
            StopCoroutine(cor_CustomAnimationBack);
            cor_CustomAnimationBack = null;
        }
        cor_CustomAnimationBack = cor_AnimationBackPlayCustomTime(startTime);
        StartCoroutine(cor_CustomAnimationBack);
    }

    IEnumerator PlayBack()
    {
        while (Animation_StartTimes.Count > 0)
        {
            float startTime = Animation_StartTimes.Dequeue();
            float PlayTime = animation_Tutorials[0][animation_Tutorials[0].clip.name].time - startTime;
            OnAnimationPlayBackCustomTime(startTime);
            yield return new WaitForSeconds(PlayTime);
        }
    }

    IEnumerator cor_AnimationPlayCustomTime(float startTime, float endTime)
    {
        animation_Tutorials[0][animation_Tutorials[0].clip.name].time = startTime;
        animation_Tutorials[0][animation_Tutorials[0].clip.name].speed = 1;
        animation_Tutorials[0].Play(animation_Tutorials[0].clip.name);
        float playTime = endTime - startTime;
        yield return new WaitForSeconds(playTime);
        animation_Tutorials[0].Stop();
        animation_Tutorials[0][animation_Tutorials[0].clip.name].time = endTime;
    }

    IEnumerator cor_AnimationBackPlayCustomTime(float startTime)
    {
        float playTime = animation_Tutorials[0][animation_Tutorials[0].clip.name].time - startTime;
        animation_Tutorials[0][animation_Tutorials[0].clip.name].speed = -1;
        animation_Tutorials[0].Play(animation_Tutorials[0].clip.name);
        yield return new WaitForSeconds(playTime);
        animation_Tutorials[0].Stop();
        animation_Tutorials[0][animation_Tutorials[0].clip.name].time = startTime;
    }
    #endregion

댓글 없음:

댓글 쓰기

git rejected error(feat. cherry-pick)

 문제 아무 생각 없이 pull을 받지않고 로컬에서 작업! 커밋, 푸시 진행을 해버렷다. push에선 remote와 다르니 당연히 pull을 진행해라고 하지만 로컬에서 작업한 내용을 백업하지 않고 진행하기에는 부담스럽다(로컬작업 유실 가능성) 해결하려...