using UnityEngine; using UnityEngine.UI; /// /// Handles RCC Canvas dashboard elements. /// [AddComponentMenu("BoneCracker Games/Realistic Car Controller/UI/RCC UI Dashboard Displayer")] [RequireComponent(typeof(RCC_DashboardInputs))] public class RCC_UIDashboardDisplay : MonoBehaviour { // Inputs of the dashboard elements. private RCC_DashboardInputs inputs; private RCC_DashboardInputs Inputs { get { if (inputs == null) inputs = GetComponent(); return inputs; } } public DisplayType displayType = DisplayType.Full; // Current display type. public enum DisplayType { Full, Customization, TopButtonsOnly, Off } public RCC_CarControllerV3 vehicle; //public bool autoAssignVehicle = true; // Buttons, texts, images, and dropdown menus. [Header("Panels")] public GameObject gauges; [Header("Texts")] public Text RPMLabel; public Text KMHLabel; public Text GearLabel; [Header("Colors")] public Color color_On = Color.yellow; public Color color_Off = Color.white; private void LateUpdate() { // If inputs are not enabled yet, disable it and return. if (!Inputs.enabled) return; if (!vehicle) return; if (RPMLabel) RPMLabel.text = Inputs.RPM.ToString("0"); if (KMHLabel) { if (RCC_Settings.Instance.units == RCC_Settings.Units.KMH) KMHLabel.text = Inputs.KMH.ToString("0") + "\nKMH"; else KMHLabel.text = (Inputs.KMH * 0.62f).ToString("0") + "\nMPH"; } if (GearLabel) { if (!Inputs.NGear && !Inputs.changingGear) GearLabel.text = Inputs.direction == 1 ? (Inputs.Gear + 1).ToString("0") : "R"; else GearLabel.text = "N"; } } public void SetDisplayType(DisplayType _displayType) { displayType = _displayType; } }