public void Play(LegacyAnimationData animData, float blendingTime, float normalizedTime)
    {
        if (animData == null)
        {
            return;
        }

        if (currentAnimationData != null)
        {
            currentAnimationData.speed           = currentAnimationData.originalSpeed;
            currentAnimationData.normalizedSpeed = 1;
        }

        currentAnimationData = animData;

        if (blendingTime == 0)
        {
            animator.Play(currentAnimationData.clipName);
        }
        else
        {
            animator.CrossFade(currentAnimationData.clipName, blendingTime);
        }

        currentAnimationData.animState.normalizedTime = normalizedTime;
        SetSpeed(currentAnimationData.speed);
        animator.Sample();
    }
    public void AddClip(AnimationClip clip, string newName, float speed, WrapMode wrapMode)
    {
        if (GetAnimationData(newName) != null) Debug.LogWarning("An animation with the name '" + newName + "' already exists.");
        LegacyAnimationData animData = new LegacyAnimationData();
        animData.clip = (AnimationClip)Instantiate(clip);
        if (wrapMode == WrapMode.Default) wrapMode = animator.wrapMode;
        animData.clip.wrapMode = wrapMode;
        animData.clip.name = newName;
        animData.clipName = newName;
        animData.speed = speed;
        animData.originalSpeed = speed;
        animData.length = clip.length;
        animData.wrapMode = wrapMode;

        List<LegacyAnimationData> animationDataList = new List<LegacyAnimationData>(animations);
        animationDataList.Add(animData);
        animations = animationDataList.ToArray();

        animator.AddClip(clip, newName);
        animator[newName].speed = speed;
        animator[newName].wrapMode = wrapMode;

        foreach (AnimationState animState in animator) {
            if (animState.name == newName) animData.animState = animState;
        }
    }
Beispiel #3
0
 public void SetSpeed(LegacyAnimationData animData, Fix64 speed) {
     if (animData != null) {
         animData.speed = speed;
         animData.normalizedSpeed = speed / animData.originalSpeed;
         if (IsPlaying(animData)) SetSpeed(speed);
     }
 }
Beispiel #4
0
    public void AddClip(AnimationClip clip, string newName, Fix64 speed, WrapMode wrapMode, Fix64 length) {
        if (GetAnimationData(newName) != null) Debug.LogWarning("An animation with the name '" + newName + "' already exists.");
        LegacyAnimationData animData = new LegacyAnimationData();
        animData.clip = (AnimationClip)Instantiate(clip);
        if (wrapMode == WrapMode.Default) wrapMode = animator.wrapMode;
        animData.clip.wrapMode = wrapMode;
        animData.clip.name = newName;
        animData.clipName = newName;
        animData.speed = speed;
        animData.originalSpeed = speed;
        animData.length = length;
        animData.wrapMode = wrapMode;

        List<LegacyAnimationData> animationDataList = new List<LegacyAnimationData>(animations);
        animationDataList.Add(animData);
        animations = animationDataList.ToArray();

        animator.AddClip(clip, newName);
        animator[newName].speed = (float)speed;
        animator[newName].wrapMode = wrapMode;


        foreach (AnimationState animState in animator) {
            if (animState.name == newName) animData.animState = animState;
        }
    }
 public void SetNormalizedSpeed(LegacyAnimationData animData, float normalizedSpeed)
 {
     animData.normalizedSpeed = normalizedSpeed;
     animData.speed           = animData.originalSpeed * animData.normalizedSpeed;
     if (IsPlaying(animData))
     {
         SetSpeed(animData.speed);
     }
 }
Beispiel #6
0
    void Start() {
        if (animations[0] == null) Debug.LogWarning("No animation found!");
        currentAnimationData = animations[0];

        if (overrideAnimatorUpdate) {
            foreach (AnimationState animState in animator) {
                animState.speed = 0;
            }
        }
    }
Beispiel #7
0
    public void Play(LegacyAnimationData animData, Fix64 blendingTime, Fix64 normalizedTime) {
        if (animData == null) return;

        if (currentAnimationData != null) {
            currentAnimationData.speed = currentAnimationData.originalSpeed;
            currentAnimationData.normalizedSpeed = 1;
        }

        currentAnimationData = animData;

        if (blendingTime == 0 || 
            ((UFE.isConnected || UFE.config.debugOptions.emulateNetwork) && UFE.config.networkOptions.disableBlending)) {
            animator.Play(currentAnimationData.clipName);
        } else {
            animator.CrossFade(currentAnimationData.clipName, (float)blendingTime);
        }
        
        SetSpeed(currentAnimationData.speed);
        deltaDisplacement = new Vector3();

        SetCurrentClipPosition(normalizedTime);
    }
 public bool IsPlaying(LegacyAnimationData animData)
 {
     return (currentAnimationData == animData);
 }
Beispiel #9
0
 public Fix64 GetSpeed(LegacyAnimationData animData) {
     return animData.speed;
 }
 public bool IsPlaying(LegacyAnimationData animData)
 {
     return(currentAnimationData == animData);
 }
Beispiel #11
0
 public Fix64 GetNormalizedSpeed(LegacyAnimationData animData) {
     return animData.normalizedSpeed;
 }
Beispiel #12
0
    void Start()
    {
        if (animations[0] == null) Debug.LogWarning("No animation found!");
        currentAnimationData = animations[0];

        if (overrideAnimatorUpdate) {
            foreach (AnimationState animState in animator) {
                animState.speed = 0;
            }
        }
    }
Beispiel #13
0
 public void SetSpeed(LegacyAnimationData animData, float speed)
 {
     if (animData != null) {
         animData.speed = speed;
         animData.normalizedSpeed = speed / animData.originalSpeed;
         if (IsPlaying(animData)) SetSpeed(speed);
     }
 }
Beispiel #14
0
 public void SetNormalizedSpeed(LegacyAnimationData animData, float normalizedSpeed)
 {
     animData.normalizedSpeed = normalizedSpeed;
     animData.speed = animData.originalSpeed * animData.normalizedSpeed;
     if (IsPlaying(animData)) SetSpeed(animData.speed);
 }
 public float GetSpeed(LegacyAnimationData animData)
 {
     return(animData.speed);
 }
Beispiel #16
0
 public float GetSpeed(LegacyAnimationData animData)
 {
     return animData.speed;
 }
Beispiel #17
0
 public float GetNormalizedSpeed(LegacyAnimationData animData)
 {
     return animData.normalizedSpeed;
 }
 public float GetNormalizedSpeed(LegacyAnimationData animData)
 {
     return(animData.normalizedSpeed);
 }
Beispiel #19
0
    public void Play(LegacyAnimationData animData, float blendingTime, float normalizedTime)
    {
        if (animData == null) return;

        if (currentAnimationData != null) {
            currentAnimationData.speed = currentAnimationData.originalSpeed;
            currentAnimationData.normalizedSpeed = 1;
        }

        currentAnimationData = animData;

        if (blendingTime == 0) {
            animator.Play(currentAnimationData.clipName);
        } else {
            animator.CrossFade(currentAnimationData.clipName, blendingTime);
        }

        currentAnimationData.animState.normalizedTime = normalizedTime;
        SetSpeed(currentAnimationData.speed);
        animator.Sample();
    }