void Update() { instance = this; if (mainCamera.transform.position.magnitude > maxOriginDistance) { MoveOrigin((Vector3d)mainCamera.transform.position); } float hfov = Mathf.Rad2Deg * 2f * Mathf.Atan(Mathf.Tan(mainCamera.fieldOfView * Mathf.Deg2Rad * .5f) * mainCamera.aspect); cameraPerspectiveScale = Screen.width / (2f * Mathf.Tan(hfov * .5f)); }
void UpdateUI() { if (gravity.planet) { double alt = gravity.distToPlanet - (gravity.planet.radius + gravity.planet.waterHeight); altitudeText.text = ScaleSpace.DisplayDistanceMeasure(alt); radarAltText.text = ScaleSpace.DisplayDistanceMeasure(gravity.distToPlanet - gravity.planet.GetHeight(gravity.planet.rotation.inverse * (Vector3d)gravity.up)); // atmosphere UI if (gravity.planet.hasAtmosphere) { atmoSliderBar.gameObject.SetActive(true); atmoSliderIcon.anchoredPosition = new Vector2( (float)Mathd.Clamp01(alt / gravity.planet.atmosphereHeight) * atmoSliderBar.rectTransform.rect.width, 0); atmoSliderBar.materialForRendering.SetFloat("_Hr", gravity.planet.reyleighScaleDepth); atmoSliderBar.materialForRendering.SetFloat("_Hm", gravity.planet.mieScaleDepth); double pressure = gravity.planet.AtmosphereDensity(gravity.distToPlanet); pressureText.text = pressure.ToString("f4") + " atm"; } else { pressureText.text = "------ atm"; atmoSliderBar.gameObject.SetActive(false); } } else { altitudeText.text = "------ m"; radarAltText.text = "------ m"; pressureText.text = "------ atm"; atmoSliderBar.gameObject.SetActive(false); } landText.color = landing ? new Color(1f, .5f, 0f) : canLand ? Color.green : Color.white * .65f; landProgressBar.sizeDelta = new Vector2((landProgressBar.parent as RectTransform).rect.width * landProgress, landProgressBar.sizeDelta.y); speedText.text = ScaleSpace.DisplaySpeedMeasure(rbody.velocity.magnitude); if (warping) { warpText.text = "WARPING"; warpText.color = Color.white; } else { if (canWarp) { if (engageWarp) { warpText.text = "WARP: " + (int)(warpEngageTimer + .5f); warpText.color = Color.white; } else { warpText.color = Color.green; warpText.text = "WARP AVAILABLE"; } } else { warpText.color = new Color(.9f, 0f, 0f); warpText.text = "WARP UNAVAILABLE"; } } }
void Awake() { instance = this; layer = LayerMask.NameToLayer("ScaledSpace"); }