public void LateUpdate() //modify UI in late update or KSP default overrides afaik { try { if (_tumbler == null || _tumbler.tumbler == null) { _tumbler = UnityEngine.Object.FindObjectOfType <KSP.UI.Screens.Flight.AltitudeTumbler>(); lhBtn = _tumbler.gameObject.AddComponent <Button>(); lhBtn.onClick.AddListener(() => { lhButtonClick(); }); AddText(); } if (FlightGlobals.speedDisplayMode == FlightGlobals.SpeedDisplayModes.Surface && LHFlightData.lhGUImodeStatic == 1 || FlightGlobals.speedDisplayMode == FlightGlobals.SpeedDisplayModes.Surface && LHFlightData.lhGUImodeStatic == 2 || LHFlightData.lhGUImodeStatic == 4) //only override if in surface mode { _tumbler.tumbler.SetValue(heightToLand()); } if (spdDisp != FlightGlobals.speedDisplayMode) //how we detect mouse click on speed display mode. { SetGUITextMode(); } } catch { //no tumbler object found, we hit this on scene change, silently fail } }
//modify UI in late update or KSP default overrides afaik //public void Start() //{ // Debug.Log("Landing Height v1.5 start."); //} public void LateUpdate() { // print(FlightUIController.speedDisplayMode); try { if (_tumbler == null || _tumbler.tumbler == null) { _tumbler = UnityEngine.Object.FindObjectOfType<KSP.UI.Screens.Flight.AltitudeTumbler>(); } if (FlightGlobals.speedDisplayMode == FlightGlobals.SpeedDisplayModes.Surface) //only override if in surface mode { //UnityEngine.Object[] tumblers = UnityEngine.Object.FindObjectsOfType<KSP.UI.Screens.Flight.AltitudeTumbler>(); //Debug.Log("cnt " + tumblers.Length); //FlightUIController.speedDisplayMode. //FlightUIController UI = FlightUIController.fetch; //UI.alt.setValue(heightToLand()); _tumbler.tumbler.SetValue(heightToLand()); //Debug.Log(FlightUIController.fetch.alt. //FlightUIController.fetch.alt.setValue(heightToLand()); } } catch(Exception e) { //Debug.Log("LH " + e); //no tumbler object found, we hit this on scene change, silently fail } }