How it works...

This recipe is very similar to the previous one but uses a different concept for the black screen animation. Instead of animating the color value, we are animating the position of the black screen to create the swipe effect. This recipe has several key elements that are different from the precious recipe:

  • Animating Left and Right positions: Our UI BlackScreen game object has its anchors set to stretch in both X and Y coordinates to make it cover the whole screen. With this anchor type, LeftRightTop, and Bottom position parameters work as offsets from the screen edge. So setting them to 0 means that the game object will cover the whole screen. The goal of setting the Right position to -20 pixels and the Left position to a number bigger than the Game View screen resolution was to put our BlackScreen game object completely off screen on the right. This way we were able to hide it in game and animate its position later.
  • Canvas Scaler: We were using a new component, the Canvas Scaler. This component's job is to scale the whole UI canvas to fill the whole screen. If we didn't use this component, our black screen wouldn't cover the whole screen after changing the screen resolution.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.218.228.99