| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- 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();
- }
- /// <summary>
- /// 给Button添加事件
- /// </summary>
- 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);
- }
- }
- /// <summary>
- /// 撤销上一步操作
- /// </summary>
- private void RevokeBtnClick()
- {
- DeviceStateManager.Instance.RemoveObjToPool();
- }
- /// <summary>
- /// 退出操作
- /// </summary>
- private void CloseButtonClick()
- {
- Application.Quit();
- //SceneManager.LoadScene("MainScene");
- //QILunjiManager.Instance.RemoveAllFromPool();
- }
- /// <summary>
- /// 撤销所有操作
- /// </summary>
- private void RevokeAllBtnClick()
- {
- DeviceStateManager.Instance.RemoveAllFromPool();
- }
- /// <summary>
- /// 相机移动
- /// </summary>
- 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
- }
|