【ハルシオンブログ】DoTweenのSequenceにOnCompleteつけてやりたいんだけど、うまくいかなかったんよ。結果できました!
こんにちは!くっそ暑い日が続いてますね!
部屋から出たら死にそうになります。坂内です。
さて、本日はDoTweenの話。
DoTweenのSequenceって皆さんお使いになられてますか?
簡単に連続してTweenができる優れもの。
例えば、こんな感じにImageを並べて

こんな感じにコードを書けば。
【DoTweenTest.cs】
こうなります。

DoTweenのTweenスタート時、Tween終了時に処理を加えることができます。
【DoTweenTest.cs】
OnStartはちゃんと入るのですが、OnCompleteを書こうとすると、エラーになって書けない…
書き方がいけないのかな?

ここじゃない?
ここ?

ここも違う?どこ?

ここも違う!!
こうなったら先生がゴロゴロしているツイッターにきいてやれ!
で、先生がいうには。

なんだって!?ヽ(゚Д゚;)ノ!!
【DoTweenTest.cs】
こんな書き方できるらしいっす。
さすが先生。
これで、シーケンス使ったDoTweenで、最初や最後に別関数を呼べますね!
それでは今日はこれくらいでお暇します。
あでゅ~ノシ
部屋から出たら死にそうになります。坂内です。
さて、本日はDoTweenの話。
DoTweenのSequenceって皆さんお使いになられてますか?
簡単に連続してTweenができる優れもの。
例えば、こんな感じにImageを並べて

こんな感じにコードを書けば。
【DoTweenTest.cs】
using UnityEngine;
using UnityEngine.UI;
using DG.Tweening;
public class DoTweenTest : MonoBehaviour {
public Image[] tiles;
private void Start() {
Sequence tileSeq = DOTween.Sequence();
tileSeq.Append(tiles[0].DOFade(0f, 2f));
tileSeq.Append(tiles[1].DOFade(0f, 2f));
tileSeq.Append(tiles[2].DOFade(0f, 2f));
tileSeq.Play();
}
}
こうなります。

DoTweenのTweenスタート時、Tween終了時に処理を加えることができます。
【DoTweenTest.cs】
using UnityEngine;
using UnityEngine.UI;
using DG.Tweening;
public class DoTweenTest : MonoBehaviour {
public Image[] tiles;
private void Start() {
Sequence tileSeq = DOTween.Sequence()
.OnStart(() => {
StartProc();
});
tileSeq.Append(tiles[0].DOFade(0f, 2f));
tileSeq.Append(tiles[1].DOFade(0f, 2f));
tileSeq.Append(tiles[2].DOFade(0f, 2f));
tileSeq.Play();
}
void StartProc() {
Debug.Log("はじまり");
}
void EndProc() {
Debug.Log("終わり");
}
}
OnStartはちゃんと入るのですが、OnCompleteを書こうとすると、エラーになって書けない…
書き方がいけないのかな?

ここじゃない?
ここ?

ここも違う?どこ?

ここも違う!!
こうなったら先生がゴロゴロしているツイッターにきいてやれ!
で、先生がいうには。

なんだって!?ヽ(゚Д゚;)ノ!!
【DoTweenTest.cs】
using UnityEngine;
using UnityEngine.UI;
using DG.Tweening;
public class DoTweenTest : MonoBehaviour {
public Image[] tiles;
private void Start() {
Sequence tileSeq = DOTween.Sequence();
tileSeq.OnStart(() => StartProc());
tileSeq.Append(tiles[0].DOFade(0f, 2f));
tileSeq.Append(tiles[1].DOFade(0f, 2f));
tileSeq.Append(tiles[2].DOFade(0f, 2f));
tileSeq.OnComplete(() => EndProc());
tileSeq.Play();
}
void StartProc() {
Debug.Log("はじまり");
}
void EndProc() {
Debug.Log("終わり");
}
}
こんな書き方できるらしいっす。
さすが先生。
これで、シーケンス使ったDoTweenで、最初や最後に別関数を呼べますね!
それでは今日はこれくらいでお暇します。
あでゅ~ノシ
« 【ハルシオンブログ】Unity2018にしてVS開いたらなんか怒られた | 【ハルシオンブログ】uGUIのオブジェクトのフェードとかの話 »
コメント
通りすがりです
最初の書き方でも大丈夫ですが、OnCompleteがonCompleteになっているのでエラーが出ているのかと思います
#- | URL | 2021/02/03 09:27 [edit]
| h o m e |