GameController

If this is a new scene, we need to add GameController, as follows:

  1. In Hierarchy, click Create Empty object and name it GameController.
  2. Add the GameController script as a component.
  3. Then drag the prefab DefaultPicture from your Prefabs folder into the Default Picture Object slot.

We will spawn new pictures at the target image origin, so modify the CreateNewPicture function as follows:

File: GameController.cs    public Transform imageTarget; 
 
    public void CreateNewPicture() { 
        GameObject newPicture = Instantiate(defaultPictureObject, imageTarget); 
    } 
  1. Then in Unity, selectGameController and drag the ImageTarget into its Image Target slot.

Get Augmented Reality for Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.