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.
- 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!
- 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:
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! } }