////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2007-2020 , Inc. All Rights Reserved.
//
////////////////////////////////////////////////////////////////////////////////
using UnityEngine;
using GCSeries.Core.Extensions;
using GCSeries.Core.Utility;
namespace GCSeries.Core
{
[ExecuteInEditMode]
public sealed partial class ZFrame : MonoBehaviour
{
////////////////////////////////////////////////////////////////////////
// Inspector Fields
////////////////////////////////////////////////////////////////////////
///
/// The scale of the user's current view. At a value of 1, one
/// Unity world unit is equal to one meter.
///
[Range(0.1f, 1000.0f)]
[Tooltip(
"The scale of the user's current view. At a value of 1, one " +
"Unity world unit is equal to one meter.")]
public float ViewerScale = 1.0f;
////////////////////////////////////////////////////////////////////////
// MonoBehaviour Callbacks
////////////////////////////////////////////////////////////////////////
private void Awake()
{
this._displayAligner =
this.GetComponentInChildren();
}
private void Update()
{
// Enforce uniform scale.
this.transform.SetUniformScale(
this.ViewerScale * ZProvider.DisplayScaleFactor);
}
////////////////////////////////////////////////////////////////////////
// Public Properties
////////////////////////////////////////////////////////////////////////
///
/// The world space position of the frame.
///
///
///
/// This accounts for any impact the ZDisplayAligner might have
/// on the frame's world space position.
///
public Vector3 WorldPosition =>
this._displayAligner?.transform.position ??
this.transform.position;
///
/// The world space rotation of the frame.
///
///
///
/// This accounts for any impact the ZDisplayAligner might have
/// on the frame's world space rotation.
///
public Quaternion WorldRotation =>
this._displayAligner?.transform.rotation ??
this.transform.rotation;
///
/// A reference to the frame's associated ZDisplayAligner.
///
public ZDisplayAligner DisplayAligner => this._displayAligner;
////////////////////////////////////////////////////////////////////////
// Private Members
////////////////////////////////////////////////////////////////////////
private ZDisplayAligner _displayAligner = null;
}
}