Adding pictures to the gallery
Please find 10 of your favorite photos from your photo library to use and add them to a new Project Assets
folder named Photos
. We are going to write a script that, given the list of images, will add them to each of the ArtworkRigs in the scene:
- To create the photos folder, navigate to
Assets
|Create
|Folder
and name itPhotos
- Import 10 photos by dragging and dropping them from your
File Explorer
into thePhotos
folder that you just created (or navigate toAssets
|Import
New Asset...
)
Now, we'll write a script to populate Artworks Images
:
- In
Hierarchy
, selectArtworks
. Then, inInspector
, navigate toAdd Component
|New Script
and name itPopulateArtFrames
. - Open the new script for editing.
Write the code for PopulateArtFrames.cs
, as follows:
using UnityEngine; public class PopulateArtFrames : MonoBehaviour { public Texture[] images; void Start() { int imageIndex = 0; foreach (Transform artwork in transform) { GameObject...