- Home /
Is there any way to use "from" value and "to" value in a single iTween call ?
Question about iTween ,
Is there any way to use "from" value and "to" value in a single iTween call ?
I want to fade a guiTexture (including all its child) from 1 to 0 alpha value whenever gameObject is enabled ,
I'm trying to do it using iTween. FadeFrom/iTween. FadeTo, On first call iTween changes alpha value from 1 to 0 , however on second call, iTween changing the value from 0 to 0 ....which makes no sense.
Hence , please let me know if I can pass both "from" and "to" values to itween so that everytime it fades from 1 to 0 value. or let me know if there is any other workaround for this
Thanks in advance :-)
Answer by chetanisinanand · Jan 28, 2015 at 09:56 PM
This will help someone if they have the same issue:
//Method below will completely Fade out object from alpha:0 to alpha:1 irrespective of object's current alpha value.
void FadeOut(){
iTween.FadeFrom (gameObject, iTween.Hash(
"alpha",0,
"time" , 1f,
"delay",0.0f,
"oncomplete","OnCompleteFadeTo",
"oncompletetarget",gameObject
));
}
public void OnCompleteFadeTo(){
iTween.FadeTo (gameObject, iTween.Hash(
"alpha",1,
"time" , 1f
));
}
Answer by federicopintaluba · Jan 05, 2015 at 02:46 PM
Add a callback when the process is complete, if you are using an iTweenHash, add the next parameter: "oncomplete", "MyFunction".
Then create MyFunction(){ float aux = a; a = b; b = aux; }
That will swap your values
Your answer
![](https://koobas.hobune.stream/wayback/20220613175649im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
iTween FadeTo() problem 1 Answer
iTween FadeTo 1 Answer
how to move or fade GUITextures with iTween 2 Answers
How to best optimise this script 1 Answer