Meta Gaze is an interaction technique that allows you to interact with objects in the center of your view. It works by emitting a raycast from the center of the MetaCameraRig Prefab in the direction you are looking.

The GazeExampleScript component demonstrates the Meta Gaze API. Specifically, it controls the colors, highlights, and materials that are be applied to the associated GameObject as the user’s gaze interaction moves onto and away from the GameObject. Note that it requires the object to have a Collider component.

Getting Started

For a GameObject to respond to a Gaze event, it must contain a MonoBehaviour or MetaBehaviour script component that implements one or both of the gaze events:

  • Meta.IGazeStartEvent triggers when the user’s gaze centers on the GameObject and calls OnGazeStart.
  • Meta.IGazeEndEvent triggers when the user’s gaze moves away from the GameObject and calls OnGazeEnd.

If you use both the IGazeStartEvent and IGazeEndEvent interfaces, your script will look similar to the following:

using Meta;

public class GazeExampleScript : MonoBehaviour, IGazeStartEvent, IGazeEndEvent
{
    public void OnGazeStart()
    {
        // This method is called when the user begins to gaze at this GameObject
    }
    public void OnGazeEnd()
    {
        // This method is called when the user looks away from this GameObject
    }
}  

Example Scene

For a demonstration of the Meta Gaze feature, refer to the Gaze Unity scene located at
Assets > MetaSDK > MetaExamples > Scenes > Gaze.

Each of the cubes arrayed in front of you have the GazeExampleScript component. Consequently, each will grow brighter as you center your gaze on it and grow dimmer as you look away.