using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using UnityEngine.EventSystems; using UnityEngine.SceneManagement; public class UIManager : MonoBehaviour { public static UIManager instance; #region 变量声明 //撤销全部按钮 public Button RevokeAll_btn; //撤销按钮 public Button Revoke_btn; RaycastHit _Hit; Ray _Ray; #endregion #region 私有方法 private void Awake() { instance = this; BtnAddClick(); } private void Update() { if (Input.GetMouseButtonDown(0)) { _Ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (!EventSystem.current.IsPointerOverGameObject()) { if (Physics.Raycast(_Ray, out _Hit)) { DeviceStateManager.Instance.AddObjToPool(_Hit.transform.gameObject); } } } //相机移动 CameraMove(); } /// /// 给Button添加事件 /// private void BtnAddClick() { RevokeAll_btn.onClick.AddListener(RevokeAllBtnClick); Revoke_btn.onClick.AddListener(RevokeBtnClick); } private void OnOriginalDisplayToggleClick(bool isOn) { if (isOn) { RevokeAll_btn.gameObject.SetActive(false); Revoke_btn.gameObject.SetActive(false); RevokeAllBtnClick(); } else { RevokeAll_btn.gameObject.SetActive(true); Revoke_btn.gameObject.SetActive(true); } } /// /// 撤销上一步操作 /// private void RevokeBtnClick() { DeviceStateManager.Instance.RemoveObjToPool(); } /// /// 退出操作 /// private void CloseButtonClick() { Application.Quit(); //SceneManager.LoadScene("MainScene"); //QILunjiManager.Instance.RemoveAllFromPool(); } /// /// 撤销所有操作 /// private void RevokeAllBtnClick() { DeviceStateManager.Instance.RemoveAllFromPool(); } /// /// 相机移动 /// private void CameraMove() { //transform.Translate(Input.GetAxis("Horizontal") * Time.deltaTime * 10f, 0, 0); //transform.Translate(0, 0, Input.GetAxis("Vertical") * Time.deltaTime * 10f); //if (Input.GetMouseButton(1)) //{ // _Rota.x -= Input.GetAxis("Mouse Y") * 60f * Time.deltaTime; // _Rota.y += Input.GetAxis("Mouse X") * 60f * Time.deltaTime; // Quaternion Q = Quaternion.Euler(_Rota); // transform.rotation = Q; //} } #endregion }