Making a resizable panel

Sometimes, UI elements require some kind of interaction with the player. This recipe, along with the previous and the following ones, will teach you how to create interactive panels. Furthermore, we will see how to make a panel resizable. For instance, the player will be able to resize the panel by dragging one of its corners. This is useful when the UI is full of panels and windows and we want to let the player choose their dimension to suit his needs. To do this, we will use the Event Trigger (Script) component and develop a script to handle the interaction.

How to do it...

  1. First, we can create a panel by right-clicking on the Hierarchy panel and then clicking on the UI | Panel. Rename it to ResizablePanel. We should also ...

Get Unity UI Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.