L
L
LeoCh23402019-11-05 20:50:05
C++ / C#
LeoCh2340, 2019-11-05 20:50:05

How to make a smooth background (sprite) change in Unity 2D?

Smooth change of background (sprite) on Unity 2d using c# script. I searched on the Internet, but I did not find working methods. I'm new, hope you explain in detail.
Thanks in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Emil, 2019-11-05
@DyadyaEmil

Hey! All you need to do is change the alpha channel of the old sprite by making it smaller, and meanwhile increase the alpha channel of the new sprite.
I could make spelling mistakes in the code, but I think the meaning is clear.
To find the answer in Google, formulate the question like this - "How to change the alpha channel of a sprite in Unity".
Alternatively, do this.
1) Lower the sprite's alpha channel to 0
2) Check: If the sprite's alpha channel = 0, then gameobject.GetComponent().sprite = "new sprite";
3) Increase the alpha channel of the sprite to 1;
I hope I could help you)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question