/* Update is called once per frame Each frame the update method is used to
  * determine the current position of each control surface, updating the text
  * box with the correct user information */
 void Update()
 {
     // update the position value
     rudderZAngle =
         ControlsUtilityMethods.WrapAngle(rudder.GetCurrentRotations().z);
     // Generate a text string for the control surface based on position
     GenerateTextDescription("rudder", rudderZAngle);
     aileronYAngle =
         ControlsUtilityMethods.WrapAngle(leftAileron.GetCurrentRotations().y);
     GenerateTextDescription("ailerons", aileronYAngle);
     elevatorYAngle =
         ControlsUtilityMethods.WrapAngle(leftElevator.GetCurrentRotations().y);
     GenerateTextDescription("elevators", elevatorYAngle);
     // Method is called to check if another UI component is covering the text box
     TextOutput();
 }
    // Start is called before the first frame update
    void Start()
    {
        // Add references to the control surface objects
        rudder       = ControlSurfaces.rudder;
        leftAileron  = ControlSurfaces.leftAileron;
        leftElevator = ControlSurfaces.leftElevator;

        // Get the relevant start angles for each surface
        rudderZAngle =
            ControlsUtilityMethods.WrapAngle(rudder.GetCurrentRotations().z);
        aileronYAngle =
            ControlsUtilityMethods.WrapAngle(leftAileron.GetCurrentRotations().y);
        elevatorYAngle =
            ControlsUtilityMethods.WrapAngle(leftElevator.GetCurrentRotations().y);

        /* Get the TextMeshPro via code. This text area is where description
         * text is shown to the user */
        var textArray = FindObjectsOfType <TextMeshProUGUI>();

        foreach (var element in textArray)  // loop through all text mesh pro objects
        {
            if (element.tag == "ControlsDescription")
            {   /* If the object is tagged as "ControlsDescription" the reference is stored
                 * in the variable allowing us to print directly into the text box through code */
                controlSurfaceDescriptions = element;
            }
        }

        // Get the UI text box background, enabling us to show and hide it
        controlInputDescriptionBackground =
            GameObject.Find("ControlsDescriptionBackground").GetComponent <Image>();

        // Store initial values of MenuSystem script booleans
        infoIsVisible     = MenuSystem.infoIsVisible;
        controlsIsVisible = MenuSystem.controlsIsVisible;
    }