12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
-
- using UnityEngine;
- using System.Collections;
- namespace Valve.VR.InteractionSystem
- {
-
- public class LinearAnimation : MonoBehaviour
- {
- public LinearMapping linearMapping;
- public new Animation animation;
- private AnimationState animState;
- private float animLength;
- private float lastValue;
-
- void Awake()
- {
- if ( animation == null )
- {
- animation = GetComponent<Animation>();
- }
- if ( linearMapping == null )
- {
- linearMapping = GetComponent<LinearMapping>();
- }
-
-
- animation.playAutomatically = true;
- animState = animation[animation.clip.name];
-
-
-
- animState.wrapMode = WrapMode.PingPong;
- animState.speed = 0;
- animLength = animState.length;
- }
-
- void Update()
- {
- float value = linearMapping.value;
-
- if ( value != lastValue )
- {
- animState.time = value * animLength;
- }
- lastValue = value;
- }
- }
- }
|