17
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

クラス変数をDOTweenする

Last updated at Posted at 2017-04-11

DOTween http://dotween.demigiant.com/ でクラス変数をトゥイーンさせるとき、ややこしくていつも忘れてしまうので、そのメモです。

##やりかた

dotween
public float piyo = 0;

void hoge(){
	//piyo を tgt に time時間 でトゥイーン
	var tgt = 100f;
	var time = 1f;
	DOTween.To (()=>piyo, (value)=>piyo = value, tgt, time).SetEase(Ease.InOutSine).OnComplete(hogeCallback);
}

void hogeCallback(){
	//終了したら呼ばれます
}

なんとVector3とかでもいけます。

dotween
public Vector3 piyo = 0;

void hoge(){
	//piyo を tgt に time時間 でトゥイーン
	var tgt = new Vector3(1f,2f,3f);
	var time = 1f;
	DOTween.To (()=>piyo, (value)=>piyo = value, tgt, time).SetEase(Ease.InOutSine).OnComplete(hogeCallback);
}

void hogeCallback(){
	//終了したら呼ばれます
}

違うやり方

こっちのほうが手軽

dotween
//DOVirtual.Float(from, to, duration, onUpdate)
DOVirtual.Float(0f, 100f, 3f, value =>
{
  Debug.Log("value: " + value);
  hoge = value;
});

参考にしたページ

17
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
17
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?