The following code is NOT working:
ExecuteMe(){
ChangeGameObjectTextMeshAlphaColor(0f);
iTween.FadeTo(gameObject, iTween.Hash ("alpha", 1f, "time", 2f,
"oncomplete", "ReturnToOriginalAlphaTransparencyTweenOnComplete", "oncompletetarget", gameObject));
}
However, the following code is working:
ExecuteMe(){
ChangeGameObjectTextMeshAlphaColor(1f);
iTween.FadeFrom(gameObject, iTween.Hash ("alpha", 0f, "time", 0.2f,
"oncomplete", "ReturnToOriginalAlphaTransparencyTweenOnComplete", "oncompletetarget", gameObject));
Unfortunately when the above code is executed a second time (or third, forth…), it does not work anymore. I mean, the game object keep being transparent.
The text I’m fading from transparent to opaque is a Text Mesh. The rest of the functions are next:
private void ReturnToOriginalAlphaTransparencyTweenOnComplete () {
//iTween.MoveTo(gameObject,iTween.Hash("position",startingPosition,"time",0.5f,"delay",3f));
iTween.FadeTo(gameObject, iTween.Hash ("alpha", 0f, "time", 2f, "delay", 1f));
}
///<summary>
/// Changes the alpha color of the text mesh of this game object.
///</summary>
///<returns>The game object text mesh alpha color.</returns>
///<paramname="alphaColor">0 would set the color to transparent. 1 without any transparency</param>
private void ChangeGameObjectTextMeshAlphaColor (float alphaColor){
Color scoreMultiplierColorInSceneView = GetComponent<TextMesh> ().color;
scoreMultiplierColorInSceneView.a = alphaColor;
GetComponent<TextMesh> ().color = scoreMultiplierColorInSceneView;
}
Why is happening that weird behaviour?