http://www.holoville.com/hotween/
iTweenよりもいいっぽいことを書いてたので使ってみる。
ダウンロードできるDLLは、
HOTweenとHOTweenMicroの2種類があるが、
HOTweenMicroはスマフォ向けなので、こっちを使いたい。
・使い方
1. Pluginsに入れる。
2. インポート
using Holoville.HOTween; using Holoville.HOTween.Plugins;
何をusingするかの記述が見つからなかったと思ったが、
WebサイトのURLが「holoville」なので気が付いた・・。
しかし、Get Startedのページにきちんと書いてる。
http://www.holoville.com/hotween/getStarted.html
DLLになってるのは便利だが、ドキュメントが充実してないので、
ソースを見る羽目になるが、
http://code.google.com/p/hotween/source/checkout
にある。
TimeScaleを無視するためのignoreオプションは見つからなかったが、
URL: http://forum.unity3d.com/threads/118515-HOTween-a-fast-and-powerful-Unity-tween-engine/page17
in HOTween you can already ignore time scale in two ways, using TweenParms: 1) use UpdateType.TimeScaleIndependentUpdate, which will totally ignore Unity's timeScale, even if set to 0 2) set your desired timeScale using the TimeScale TweenParm (which, unless you also set UpdateType to TimeScaleIndependentUpdate, will use Unity's timeScale and multiply it for HOTween's timeScale).
Time.timeScaleがたとえ0のときでもUpdateしたいときには、
HOTween.defUpdateType = UpdateType.TimeScaleIndependentUpdate;
で、できる!
HOTween.To(myGameObject.transform, 1, new TweenParms().Prop("position", new Vector3(10,20,30)).OnComplete(MyFunction)); private void MyFunction() { // Your code here }
このように変化させたい値を文字列にする
少し変な感じがするけど、positionを文字列で記載。
MyFunctionは、終了時に呼ばれるコールバック。
「MyFunction()」ではなく「MyFunction」で記載するのに注意。
1はdurationなので移動するときの全体時間。
ちなみに、myGameObject.transformではなくて、
一旦、変数に格納したほうがいいのかもしれない。
裏でキャッシュしてるかもしれないけど。