using Google.Maps.Examples.Shared; using UnityEngine; /// /// A controller that updates some onscreen HUD elements based on the status of a /// SimpleViewController on a camera rig. /// public class CompassAltimeterUpdater : MonoBehaviour { /// /// The from which to get altitude and Azimuth. /// [Tooltip("The controller from which to get altitude and Azimuth.")] public SimpleViewController SimpleViewController; /// /// object to update based on Azimuth. /// [Tooltip("Compass object to update based on Azimuth.")] public GameObject Compass; /// /// object to update based on transform.y of the SimpleViewController. /// [Tooltip("Altimeter object to update based on transform.y of the SimpleViewController.")] public GameObject Altimeter; /// /// Movement scale used when updating Altimeter object. /// /// /// This value is configured based on the unity world scale size of the altimeter object. The /// current altitude (position.y of ) is multiplied by this /// scale factor to get the calibrated vertical movement of the altitude strip. /// [Tooltip("Movement scale used when updating Altimeter object.")] public float AltimeterScale = 4.0f; void Update() { // Rotate the compass to align with Azimuth. if (Compass != null) { Compass.transform.localRotation = Quaternion.Euler(0, 0, SimpleViewController.Azimuth - 180); } // Move Altimeter based on y position of SimpleViewController and AltimeterScale. if (Altimeter != null) { float altHeight = -SimpleViewController.transform.position.y * AltimeterScale; Altimeter.transform.localPosition = new Vector3(0, altHeight, 0); } } }