- Home /
iTween Visual Editor, Help!
Hello, I would like to be able to add iTween event using visual editor, and on that iTween Event set a parameter and target game object that says when this animation is completed start the animation on the other game object.
WHAT AM I DOING WRONG:
Obj A has a iTweenEvent with >> iTween Visual Editor NOT CODED SCRIPT on it that has this checked: oncomplete: (name of Obj B's iTweenEvent Visual Inspector Script), and Obj A also has this checked: oncompletetarget: (Transform of Obj B, that has the NEXT animation on it I want to start as SOON as Obj A's animation is complete).
Picture of Obj A's iTween Visual Editor Inspector Script:
Picture of Obj B's iTween Visual Editor Inspector Script:
Thanks for the Help Daniel
PS: I take the time to Mark and rate all good answers!
PS: I have read all documentation But there is NO documentation for the Visual Editor! I Although the same Principles $$anonymous$$UST carry over I don't understand the logic in Callbacks either So any help with Logic would GREATLY be appreciated!
@aldonaletto I don't expect you to answer this question, but I know you love progra$$anonymous$$g and have helped me in the past! If you have a $$anonymous$$ute, and can understand my mutilated way of using iTween and show me how to do it right! I would me much obliged!
Hello, is there any one with experience with iTween that could give me some pointers?
Answer by Daniel G · Jul 24, 2013 at 04:07 PM
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!
}
}
Hope this Helps EveryOne out there! Daniel G