- Home /
First Use of Leantween.Alpha in scene
Hello guys, I have a problem with very first use of Leantween.Alpha in game... I am starting with deactivated gameobject and with Alpha value of Ui.Image on 0.
On start function I call Show() and then, I just for simulating, that things working calling Hide,show on complete, as posted here. But On the very first use of Show() Image just appear without fade effect... On each other Hide/Show images are fading perfectly, but the very first is always just appeared... I also tried to call the Show() function from Coroutine to make sure, that everything is prepared on start, but same issue... Any ideas?
public void Show()
{
this.gameObject.SetActive(true);
LeanTween.alpha(this.image.rectTransform, 1f, 2f).setOnComplete(this.Hide);
}
public void Hide()
{
LeanTween.alpha(this.image.rectTransform, 0, 2f).setOnComplete(this.Show);
}
Answer by juancvv · Jul 16, 2019 at 04:29 PM
Hi, I have solved this using value leanTween function:
Image r = gameObject.GetComponent<Image>();
LeanTween.value(gameObject, 0, 1, 1).setOnUpdate((float val) =>
{
Color c = r.color;
c.a = val;
r.color = c;
});
Hi Juancw, Thank you! :) I am using leantween.value also until then :) That question is quite old :D
Your answer
![](https://koobas.hobune.stream/wayback/20220612102421im_/https://answers.unity.com/themes/thub/images/avi.jpg)