Adding the frame menu

Our Frame menu will present a list of three picture frames. When the user chooses one, it will replace the current frame used in the picture. It will work like this;

  • User selects the Frame button from the toolbar, which opens (displays) the Frame menu
  • User selects one of the frames from the list of clickable frame objects
  • The menu tells the PictureController to set the selected frame in the picture
  • The Frame menu is closed (hidden)

The menu will call SetFrame in PictureController. This function will replace the current frame object in FramedImage with the selected one. How does it know which child object of FramedImage is the frame (and not the image)? There are a number of ways to implement this, using tags or layers, for example. We will take the approach of parenting the FramedImage frame with a new object named FrameSpawn:

  1. In Hierarchy, under FramedImage, click Create Empty and name it FrameSpawn.
  2. Move the Frame 1 object in FramedImage as a child of FrameSpawn.

The FramedImage in Hierarchy now looks like this:

Now let's write the PictureController code that will be called from the menu when the user selects a new frame.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset