Unity3d_iTweenEvent内置事件的使用

Hello Everyone! So I know this question will be asked again by someone using iTween Visual Editor, so I like to take a second to clear up any confusion when using callbacks with iTween Visual Editor.

  1. the callbacks that are listed in the iTween visual editor are for naming a message and giving it a value that is sent to all GameObjects in the hierarchy and if one of those GameObjects has a script attached to it that WANTS that oncomplete "callBack" or onupdate "CallBack" then it can trigger that OTHER functions separate from iTween OR call more iTween events!
  2. So if your looking for a way to call another animation OR other functions in your game here is how you do it!

First Set up a iTween Visual Editor component on the game object you want to animate:

Like so:

alt text

THEN Check oncomplete and give it a value such as "LoopAnimationAgain" THIS will be your function in your script! THEN IF it is a dieffernt game object that your script will be resting, THEN drag that OTHER game obj into the oncompletetarget area (check it first) THEN DIFINE a Parameter! This is like a VALUE for that FUNCTION! SO in my script i am attaching below, you can set that as the method : String! And if you wanted you could have SEVERAL methods (Methods = the VALUE for the Function).

Case is a specific VALUE of the FUNCTION. WHEN that VALUE or Case or Method (all the same thing) is sent FROM the iTween Visual Editor script (see picture above), it will Trigger the (coded) script on the other GameObject to DO SOMETHING! Here is the Example! This is STRIPPED from my code for my PlayButton:

Code:

//For animation of LoadingScreen
var TriangleTwist : GameObject;
var TriangleOne : GameObject;
var TriangleTwo : GameObject;
var TriangleThree : GameObject;
var TriangleFour : GameObject;
var LoadingGUIAnimationStartWaitTime : float = 0;

function Start () {

}

function Update () {
    LoadingAnimation ();
}


function LoadingAnimation () {
    pb = GameObject.FindGameObjectWithTag("PlayButton").gameObject.GetComponent(playButton);

    //For testing...
    //if (Input.GetKeyDown("space")) {
    if (pb.tappedOn == true) {

       Debug.Log("Input Works!");
       yield WaitForSeconds (LoadingGUIAnimationStartWaitTime);
       //Start Movement of GUI loading animation and triangle animation into view of LoadingScreen_CAM

       iTweenEvent.GetEvent(TriangleTwist, "MoveUp").Play();
       iTweenEvent.GetEvent(CubeBottom, "MoveUp").Play();
       iTweenEvent.GetEvent(CubeTop, "MoveDown").Play();
       iTweenEvent.GetEvent(TriangleTwist, "LoadingAnimationTwirl").Play();
       iTweenEvent.GetEvent(TriangleOne, "ColorFadeToWhite").Play();
       iTweenEvent.GetEvent(TriangleTwo, "ColorFadeToWhite").Play();
       iTweenEvent.GetEvent(TriangleThree, "ColorFadeToWhite").Play();
       iTweenEvent.GetEvent(TriangleFour, "ColorFadeToWhite").Play();
       iTweenEvent.GetEvent(TriangleOne, "ColorFadeToGrey").Play();
       iTweenEvent.GetEvent(TriangleTwo, "ColorFadeToGrey").Play();
       iTweenEvent.GetEvent(TriangleThree, "ColorFadeToGrey").Play();
       iTweenEvent.GetEvent(TriangleFour, "ColorFadeToGrey").Play();
    }
}

       //This "LoopAnimationAgain" = the ONCOMPLETE call from the "TriangleTwist" GameObject that HAS the iTween Event with the oncompleteparams METHOD on in and when the method is called such as "StartLoop"
       // it replays all the iTween Events!
function LoopAnimationAgain (method : String) {
switch(method){
       case "StartLoop":
       Debug.Log("THIS WORKS!!");
       iTweenEvent.GetEvent(TriangleTwist, "LoadingAnimationTwirl").Play();
       iTweenEvent.GetEvent(TriangleOne, "ColorFadeToWhite").Play();
       iTweenEvent.GetEvent(TriangleTwo, "ColorFadeToWhite").Play();
       iTweenEvent.GetEvent(TriangleThree, "ColorFadeToWhite").Play();
       iTweenEvent.GetEvent(TriangleFour, "ColorFadeToWhite").Play();
       iTweenEvent.GetEvent(TriangleOne, "ColorFadeToGrey").Play();
       iTweenEvent.GetEvent(TriangleTwo, "ColorFadeToGrey").Play();
       iTweenEvent.GetEvent(TriangleThree, "ColorFadeToGrey").Play();
       iTweenEvent.GetEvent(TriangleFour, "ColorFadeToGrey").Play();
       break;

       //You can Have MORE cases if you want with different Values!
       //case "BlahBlah"
         //Do more things here like move something or call an iTweem animation
       //break; REMEMBER to BREAK; the CALL otherwise it will call every frame!
    }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值