Last active
January 31, 2021 20:06
-
-
Save baobao/ee3d9be48c421a4723a110acebae2968 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
using DG.Tweening; | |
public class DOTweenTest : MonoBehaviour | |
{ | |
// Unity-chan Animator | |
public Animator animator; | |
IEnumerator Start () | |
{ | |
transform.localPosition = new Vector3 (0, 0, -5.8f); | |
// 再生開始 | |
var tw = transform.DOLocalPath ( | |
new Vector3[] | |
{ | |
new Vector3 (2.6f, 0, -2f), | |
Vector3.zero | |
}, | |
4f, PathType.CatmullRom) | |
.SetLookAt (0.3f, Vector3.forward) | |
.SetEase (Ease.Linear); | |
animator.SetFloat ("Speed", 1f); | |
yield return new WaitForSeconds (3f); | |
// Animator, Tween共に巻き戻し | |
animator.SetFloat ("Speed", -1f); | |
tw.PlayBackwards (); | |
yield return new WaitForSeconds (3f); | |
// Animator, Tween共に2倍速 | |
animator.SetFloat ("Speed", 2f); | |
tw.PlayForward (); | |
tw.timeScale = 2f; | |
// Tweenの終了を待機 | |
yield return tw.WaitForCompletion (); | |
// Animator, Tween共にスピードを元に戻す | |
animator.SetFloat ("Speed", 1f); | |
tw.timeScale = 1f; | |
animator.SetTrigger ("Idle"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment