public static void CreateSpriteClip() { NonBrokenSpriteAnimationClip clip = ScriptableObject.CreateInstance <NonBrokenSpriteAnimationClip>(); AssetDatabase.CreateAsset(clip, "Assets/NewSpriteAnimationClip.asset"); AssetDatabase.SaveAssets(); EditorUtility.FocusProjectWindow(); Selection.activeObject = clip; }
// Update is called once per frame void Update() { //check if we've reached the end of the animation if (currentAnimation != null && Time.time > animationEndTime) { //if it's looping, update the animation begin time to start the animation over from the beginning if (currentAnimation.animationType == NonBrokenSpriteAnimationClip.AnimationType.Looping) { animationBeginTime += currentAnimation.animationDuration; } else { currentAnimation = null; } } if (currentAnimation != null) { //update the sprite renderer with the current frame spriteRenderer.sprite = currentAnimation.spriteFrames[CurrentFrameIndex]; } }
public void BeginAnimation(NonBrokenSpriteAnimationClip clip) { currentAnimation = clip; animationBeginTime = Time.time; spriteRenderer.sprite = currentAnimation.spriteFrames[0]; }