Skip to content

Effect: Gradually increasing color on interaction and restore to original #67

Answered by KyryloKuzyk
IAFahim asked this question in FAQ
Discussion options

You must be logged in to vote

Something like this:

[SerializeField] Image buttonImage;
Sequence colorAnimation;

void Update() {
    if (Input.GetMouseButtonDown(0)) {
        colorAnimation.Stop();
        colorAnimation = Sequence.Create(Tween.Color(buttonImage, Color.black, 1));
    }
    if (Input.GetMouseButtonUp(0)) {
        colorAnimation.Stop();
        colorAnimation = Sequence.Create()
            .ChainDelay(0.5f)
            .Chain(Tween.Color(buttonImage, Color.white, 1));
    }
}

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by IAFahim
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
FAQ
Labels
None yet
2 participants