02. Developing Augmented Reality Experiences

Adrian Clark, senior lecturer, School of Product Design.

Introduction to Unity

Unity: ‘real time development platform’. Not just for games.

Unity is so big, no one knows the full extent of what it can do.

Resources:

Unity:

Editor:

Shader rendering mode:

Scripting:

// Behavior script is another component that attaches to a GameObject

// https://docs.unity3d.com/Manual/ExecutionOrder.html

// A massive number of lifecycle callbacks
public class NodeBehaviorScript: MonoBehaviour {
  // Called before first frame update
  void Start() {
    Debug.log("Instantiated");
  }

  // Called every frame
  void Update() {
    if (Input.GetKey(KeyCode.UpArrow)) {
      // transform: transform of the object the script is attached to
      // localPosition: position relative to parent
      transform.localPosition += new Vector3(0, 0, 0.1f);
    }
  }

  void onMouseDown() {
    // Set up a collider on the game object
    // e.g. box collider: invisible box (hopefully) around the object
  }

  void onCollisionEnter(Collision collision) {
    // Use collider that is larger than the object: when two objects
    // come close together you can add custom behavior (e.g. 'picking up'
    // the object in AR
  }

}

Unity Remote:

AR

Many different SDKs available. Some deciding factors:

Unity also has AR foundation: a common interface to platform-specific AR frameworks. No way of running it in the editor, which makes development very frustrating (although there are some rumblings of a Unity Remote-like app which does on-device processing).

This course will use Vuforia:

Vuforia AR camera:

Targets:

UI:

Prefabs:

Building for Mobile:

Adrian: