O'Reilly logo

NGUI for Unity by Charles Bernardoff

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The scrollable viewport

We will start by creating a clipped, draggable background, and then add linked scroll bars as shown in the following screenshot:

The scrollable viewport

Draggable background

We want the player to be able to scroll on both axes. That means we need a background both larger and taller than the screen size. For this game, we will need quite a large environment to force him or her to scroll regularly. Let's create one that is twice the screen's size.

Perform the following steps to create the environment:

  1. Select our Panel GameObject and perform the following steps:
    1. Rename it as Viewport.
    2. Set its Clipping parameter to Alpha Clip.
    3. Set its Clipping Size to 1920 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required