using DG.Tweening; using UniRx; using UnityEngine; using UnityEngine.AzureSky; using UnityEngine.UI; public class ToolBarPanel : UIView { public Text DateText; public Text TimeText; public Text CityText; public Text WeatherText; public Text TemperatureText; public Text DirectionText; public Text WindText; public LongClickButton ForceButton; public Button RotateButton; public Toggle PlaneToggle; public Toggle DistanceToggle; public Toggle HeightToggle; public Toggle AreaToggle; public Button SettingButton; public override void Awake() { base.Awake(); UIManager.Instance.Show(); Observable.EveryUpdate() .Subscribe(_ => DateTime()); PlaneToggle.gameObject.SetActive(false); //单击重置视图 ForceButton.OnClickAsObservable() .Subscribe(_ => MainMenu.Instance.OnResetCamera()); //长按重置视图恢复楼层 ForceButton.onLongClick.AddListener(() => MainMenu.Instance.OnInterialClose()); //自动旋转 RotateButton.OnClickAsObservable() .Subscribe(_ => AssetManager.Instance.MainCamera.GetComponent().isAutoRotate = true); //测距 DistanceToggle.onValueChanged.AddListener((bool value) => MeasureTools.Instance.MeasureLength(value)); //测高 HeightToggle.onValueChanged.AddListener((bool value) => MeasureTools.Instance.MeasureHeight(value)); //测面 AreaToggle.onValueChanged.AddListener((bool value) => MeasureTools.Instance.MeasureArea(value)); //平面图切换 PlaneToggle.GetComponent().onValueChanged.AddListener((bool value) => ViewModeSwitch(value)); SettingButton.onClick.AddListener(() => { UIManager.Instance.GetView().GetComponent().DOAnchorPos(new Vector2(0, 0), 0.1f); }); } private void ViewModeSwitch(bool isOn) { if (isOn) { UIManager.Instance.GetView().gameObject.GetComponent().localEulerAngles = new Vector3(0, 0, 180 - AssetManager.Instance.InitialAngle); MainMenu.Instance.ViewMode = FloorViewMode.TwoD; AssetManager.Instance.MainCamera.SetActive(false); AssetManager.Instance.PlaneCamera.SetActive(true); AzureSkyController.Instance.lightTransform.GetComponent().enabled = false; PlaneToggle.transform.Find("Label").GetComponent().text = "3D"; //PlaneToggle.transform.Find("Label").GetComponent().color = new Color(0f, 0.6f, 0.9f, 1f); //UIManager.Instance.Hide(); } else { MainMenu.Instance.ViewMode = FloorViewMode.ThreeD; AssetManager.Instance.MainCamera.SetActive(true); AssetManager.Instance.PlaneCamera.SetActive(false); AzureSkyController.Instance.lightTransform.GetComponent().enabled = true; PlaneToggle.transform.Find("Label").GetComponent().text = "2D"; //PlaneToggle.transform.Find("Label").GetComponent().color = Color.white; //Debug.Log(MainMenu.Instance.MenuMode); //if (MainMenuPanel.Instance.transform.Find("MainButtons/BuildingStructure").GetComponent().isOn) //{ // Show(); //} } } //时间日期 private void DateTime() { int _year = System.DateTime.Now.Year; int _month = System.DateTime.Now.Month; int _day = System.DateTime.Now.Day; DateText.text = string.Format("{0:D1}/{1:D2}/{2:D2}", _year, _month, _day); int _hour = System.DateTime.Now.Hour; int _minute = System.DateTime.Now.Minute; TimeText.text = string.Format("{0:D2}:{1:D2}", _hour, _minute); } }