Adding and deleting framed pictures
There's just a couple more features to add to the project. So far, we've been working with only a single picture. We want to add many pictures to decorate the walls! Fortunately, our DefaultPicture
object is very self-contained, with its toolbar and menus and all. So one approach is to save the DefaultPicture
as a prefab and then instantiate new copies of it for each new image we add to the scene.
The plan is to add Add
and Delete
buttons to the toolbar. Clicking Add
will create a new picture in the scene. Clicking Delete
will remove the current picture from the scene.
Let's set that up now.
Add and Delete in the Toolbar
We'll first add the Add
and Delete
buttons to the toolbar:
- From the Project
Assets/SimpleIcons/Prefabs
folder, drag theDeleteButton
prefab to theHierarchy
as a child ofToolbar
. - Set its
Position X
to0.15
. - Add the
PictureAction
script component to the button. - Set its
Command
toDELETE
. - From the Project
Assets/SimpleIcons/Prefabs
folder, drag...