Skip to content

Instantly share code, notes, and snippets.

@st0326s
Last active August 29, 2015 14:17
Show Gist options
  • Save st0326s/8cfffa684ac2041fe932 to your computer and use it in GitHub Desktop.
Save st0326s/8cfffa684ac2041fe932 to your computer and use it in GitHub Desktop.
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class iTweenTest : MonoBehaviour {
public Text text1;
private Hashtable table = new Hashtable(); // ハッシュテーブルを用意
// Use this for initialization
void Start () {
//**********************************************************************
// このコードを適用したgameObjectを5秒掛けて(3, 3, 3)の位置まで移動させる
//iTween.MoveTo(gameObject, new Vector3(3, 3, 3), 5.0f);
//**********************************************************************
//// Hashテーブルを使用
//table.Add("x", 10); // xを10まで移動
//table.Add("y", 5); // yを5まで移動
//table.Add("time", 3.0f); // トゥイーン時間は3秒
//table.Add("delay", 1.0f); // 1秒遅らせてからトゥイーンスタート
//iTween.MoveTo(gameObject, table); // 第二引数にハッシュテーブルをセット
//**********************************************************************
// Hashを1行
//iTween.MoveTo(gameObject, iTween.Hash("x", 10, "y", 5, "time", 3.0f, "delay", 1.0f));
////**********************************************************************
//// CallBack
//table.Add("x", 0);
//table.Add("onstart", "cb_iTweenStart"); //Handler func when iTween start
//table.Add("onstartparams", "Start"); //parameter of Handler func when iTween start
//table.Add("oncomplete", "cb_iTweenComplete"); //Handler func when iTween end
//table.Add("oncompleteparams", "Complete"); //parameter of Handler func when iTween end
//iTween.MoveTo(gameObject, table);
Vector3[] movepath = new Vector3[5];
for (int i = 0; i < 4; ++i)
{
movepath[i].Set(Random.Range(-20.0f, 20.0f), Random.Range(0.0f, 10.0f), Random.Range(0.0f, 30.0f));
}
movepath[4].Set(-1.0f, -4.1f, 34.0f);
//**********************************************************************
// CallBack
table.Add("path", movepath);
table.Add("time", 4);
table.Add("easetype", iTween.EaseType.easeOutSine);
table.Add("onstart", "cb_iTweenStart"); //Handler func when iTween start
table.Add("onstartparams", "Start"); //parameter of Handler func when iTween start
table.Add("onupdate", "cb_iTweenUpdate"); // トゥイーンを開始してから毎フレームUpdateHandler()を呼ぶ
table.Add("onupdateparams", "Update"); // UpdateHandler()の引数に渡す値
table.Add("oncomplete", "cb_iTweenComplete"); //Handler func when iTween end
table.Add("oncompleteparams", "Complete"); //parameter of Handler func when iTween end
iTween.MoveTo(gameObject, table);
// iTween.MoveTo(gameObject, iTween.Hash("path", movepath, "time", 4, "easetype", iTween.EaseType.easeOutSine));
}
void cb_iTweenStart(string param){
Debug.Log("[iTween] cb_iTweenStart: "+param);
}
void cb_iTweenComplete(string param){
Debug.Log("[iTween] cb_iTweenComplete: "+param);
}
void cb_iTweenUpdate(string param)
{
Debug.Log("[iTween] cb_iTweenUpdate: " + param);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment