Creating a framed photo prefab
The user will be placing a framed photo on their walls. So, we need to create a prefab game object that will be instantiated. We want to make it easy to change images and frames, as well as resize them for various orientations (landscape versus portrait) and image aspect ratios. For the default frame, we'll create a simple block from a flattened 3D cube and mount the photo on the face of it. For the default image, you may choose your own or use one that's included with the files for this chapter in the GitHub repository.
Creating the prefab hierarchy
First, create an empty prefab named FramedPhoto
in your project's Assets/
folder. Follow these steps:
- In the Project window, navigate to your
Prefabs/
folder (create one if needed). Then right-click in the folder and select Create | Prefab. - Rename the new prefab
FramedPhoto
. - Double-click the FramedPhoto asset (or click its Open Prefab button in the Inspector window).
We...