Skip to content

Instantly share code, notes, and snippets.

@baobao
Last active January 31, 2021 20:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save baobao/ee3d9be48c421a4723a110acebae2968 to your computer and use it in GitHub Desktop.
Save baobao/ee3d9be48c421a4723a110acebae2968 to your computer and use it in GitHub Desktop.
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