Add and Delete Commands in PictureController

In the PictureController script, add the following code to the Execute() function:

File: PictureController.cs
case PictureCommand.ADD: AddPicture(); break; case PictureCommand.DELETE: DeletePicture(); break;

Write the corresponding implementations of the commands:

    private void AddPicture() { 
        DoneEdit(); 
        GameController.instance.CreateNewPicture(); 
    } 
 
    private void DeletePicture() { 
        Destroy(gameObject); 
    } 

AddPicture will close the current picture editing and create a new picture via GameController. DeletePicture will delete the current game object.

Let's try it out. Save your work and press Play. Use the toolbar's Add button to create a new picture, move it into place, and create another. Use the Delete button to delete a picture.

Delete all the pictures in your scene. Now what? We could put an Add button in front of you, or some other mechanism for creating new pictures, apart from a current picture's toolbar. Instead, we'll always make sure there's at least one picture in the scene, with its toolbar.

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

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