// %BANNER_BEGIN%
// ---------------------------------------------------------------------
// %COPYRIGHT_BEGIN%
// Copyright (c) (2019-2022) Magic Leap, Inc. All Rights Reserved.
// Use of this file is governed by the Software License Agreement, located here: https://www.magicleap.com/software-license-agreement-ml2
// Terms and conditions applicable to third-party materials accompanying this distribution may also be found in the top-level NOTICE file appearing herein.
// %COPYRIGHT_END%
// ---------------------------------------------------------------------
// %BANNER_END%
namespace UnityEngine.XR.MagicLeap
{
///
/// Script used to position this Canvas object directly in front of the user by
/// using lerp functionality to give it a smooth look. Components on the canvas
/// should function normally.
///
[AddComponentMenu("XR/MagicLeap/MLHeadposeCanvasBehavior")]
[RequireComponent(typeof(Canvas))]
public class MLHeadposeCanvasBehavior : MonoBehaviour
{
[Tooltip("The forwards distance from the camera that this object should be placed.")]
public float CanvasDistanceForwards = 1.5f;
[Tooltip("The upwards distance from the camera that this object should be placed.")]
public float CanvasDistanceUpwards = 0.0f;
[Tooltip("The speed at which this object changes its position.")]
public float PositionLerpSpeed = 5f;
[Tooltip("The speed at which this object changes its rotation.")]
public float RotationLerpSpeed = 5f;
// The canvas that is attached to this object.
private Canvas _canvas;
// The camera this object will be in front of.
private Camera _camera;
///
/// Initializes variables and verifies that necessary components exist.
///
void Awake()
{
_canvas = GetComponent