[출처]
http://hyunity3d.tistory.com/228

유니티 필수 에셋 중에 하나인 아이트윈
유니티에서 물체의 움직임을 보다 쉽게 설정 할 수 있습니다.
유니티를 켜시고 에셋 스토어로 갑시다 ctrl + 9 를 누르면 Asset Store에 들어가집니다.
iTween 으로 검색하시면 아래와 같이 화면이 나오고 다운로드 버튼을 누르고 유니티 상에 import 시켜줍니다.


파일을 여시면 sample 소스가 존재합니다. sample 소스를 보시면 iTween 이라는게 뭐구나 하고 싶게 이해 할수있으실겁니다.

간단하게 샘플 소스에 대해 알아보겠습니다.
using UnityEngine;
using System.Collections;
public class MoveSample : MonoBehaviour
{
void Start(){
iTween.MoveBy(gameObject, iTween.Hash("x", 2, "easeType", "easeInOutExpo", "loopType", "pingPong","delay", .1));
}
}
moveSample 입니다.
MoveBy(GameObject target, Vector3 amount, float time)MoveBy(GameObject target, Hashtable args)
moveBy를 호출하는 방법은 위와 같이 두가지 방법이 있습니다.
첫번째는 호출 방법은 위치와 시간을 집어넣어주는 함수이고
두번째는 호출 방법은 해쉬테이블을 집어넣는 방식입니다.
위함수에서는
x = 2;
easeType = "easeInOutExpo"
loopType = "pingPong"
delay = .1;
해쉬테이블의 name 에 각 값들을 집어넣은 것과 같습니다.
해쉬테이블을 미리 선언하고 아래와 같이 집어넣을 수 도 있습니다.
Hashtable ht = new Hashtable();
void Awake(){
ht.Add("x",3);
ht.Add("time",4);
ht.Add("delay",1);
ht.Add("onupdate","myUpdateFunction");
ht.Add("looptype",iTween.LoopType.pingPong);
}
void Start(){
iTween.MoveTo(gameObject,ht);
}
함수의 종류는 아래와 같습니다.
Adds the supplied coordinates to a GameObject's position.
- MoveBy(GameObject target, Vector3 amount, float time)
- MoveBy(GameObject target, Hashtable args)
Property Name | Type | Purpose |
---|
name | string | an individual name useful for stopping iTweens by name |
amount | Vector3 | for a point in space the GameObject will animate to. |
x | float or double | for the individual setting of the x axis |
y | float or double | for the individual setting of the y axis |
z | float or double | for the individual setting of the z axis |
orienttopath | boolean | for whether or not the GameObject will orient to its direction of travel. False by default |
looktarget | Transform or Vector3 | for a target the GameObject will look at |
looktime | float or double | for the time in seconds the object will take to look at either the "looktarget" or "orienttopath" |
axis | string | restricts rotation to the supplied axis only |
space | Space | for applying the transformation in either the world coordinate or local cordinate system. Defaults to local space |
time | float or double | for the time in seconds the animation will take to complete |
speed | float or double | can be used instead of time to allow animation based on speed |
delay | float or double | for the time in seconds the animation will wait before beginning |
easetype | EaseType or string | for the shape of the easing curve applied to the animation |
looptype | LoopType or string | for the type of loop to apply once the animation has completed |
onstart | string | for the name of a function to launch at the beginning of the animation |
onstarttarget | GameObject | for a reference to the GameObject that holds the "onstart" method |
onstartparams | Object | for arguments to be sent to the "onstart" method |
onupdate | string | for the name of a function to launch on every step of the animation |
onupdatetarget | GameObject | for a reference to the GameObject that holds the "onupdate" method |
onupdateparams | Object | for arguments to be sent to the "onupdate" method |
oncomplete | string | for the name of a function to launch at the end of the animation |
oncompletetarget | GameObject | for a reference to the GameObject that holds the "oncomplete" method |
oncompleteparams | Object | for arguments to be sent to the "oncomplete" method |
ignoretimescale | boolean | setting this to true will allow the animation to continue independent of the current time which is helpful for animating menus after a game has been paused by setting Time.timeScale=0 |
using UnityEngine;
using System.Collections;
public class RotateSample : MonoBehaviour
{
void Start(){
iTween.RotateBy(gameObject, iTween.Hash("x", .25, "easeType", "easeInOutBack", "loopType","pingPong", "delay", .4));
}
}
RotateSample 입니다.
Multiplies supplied values by 360 and rotates a GameObject by calculated amount over time.
- RotateBy(GameObject target, Vector3 amount, float time)
- RotateBy(GameObject target, Hashtable args)
Property Name | Type | Purpose |
---|
name | string | an individual name useful for stopping iTweens by name |
amount | Vector3 | for the amount to be multiplied by 360 to rotate the GameObject. |
x | float or double | for the individual setting of the x axis |
y | float or double | for the individual setting of the y axis |
z | float or double | for the individual setting of the z axis |
space | Space or string | for applying the transformation in either the world coordinate or local cordinate system. Defaults to local space. |
time | float or double | for the time in seconds the animation will take to complete |
speed | float or double | can be used instead of time to allow animation based on speed |
delay | float or double | for the time in seconds the animation will wait before beginning |
easetype | EaseType or string | for the shape of the easing curve applied to the animation |
looptype | LoopType or string | for the type of loop to apply once the animation has completed |
onstart | string | for the name of a function to launch at the beginning of the animation |
onstarttarget | GameObject | for a reference to the GameObject that holds the "onstart" method |
onstartparams | Object | for arguments to be sent to the "onstart" method |
onupdate | string | for the name of a function to launch on every step of the animation |
onupdatetarget | GameObject | for a reference to the GameObject that holds the "onupdate" method |
onupdateparams | Object | for arguments to be sent to the "onupdate" method |
oncomplete | string | for the name of a function to launch at the end of the animation |
oncompletetarget | GameObject | for a reference to the GameObject that holds the "oncomplete" method |
oncompleteparams | Object | for arguments to be sent to the "oncomplete" method |
ignoretimescale | boolean | setting this to true will allow the animation to continue independent of the current time which is helpful for animating menus after a game has been paused by setting Time.timeScale=0 |
보다 많은 정보는 iTwwen 홈페이지에서 찾아볼수있습니다.
ITwen 홈페이지 :http://itween.pixelplacement.com/index.php
관련 동영상 강좌 입니다.
http://www.youtube.com/watch?v=qRafXt26a_E
http://www.youtube.com/watch?v=qE5hpp4YaH4
http://www.youtube.com/watch?v=hbSxwoWjBgQ -> 한글