using DG.Tweening.Core.Easing; using System.Collections; using System.Collections.Generic; using System.Linq; using UnityEngine; using UnityEngine.UI; using UnityEngine.UIElements; using static UnityEngine.Rendering.DebugUI; public class LiveSceneManager : SingletonMono { [HideInInspector] public FirstPersonController firstPersonController; //[HideInInspector] public GameObject currentTool; public Transform spawnToolPos; //public Transform tMDTips; public string triggerName; public string playSpeack; private Vector3 lastPlayerPos = new Vector3(); private Vector3 lastPlayerAngle = new Vector3(); private float lastFOV; private Vector3 lastPlayerCameraAngle = new Vector3(); protected override void Awake() { base.Awake(); firstPersonController = GameObject.FindGameObjectWithTag("Player").GetComponent(); //tMDTips.gameObject.SetActive(false); //firstPersonController.zoomAction += OnZoom; //基类全部初始化 //device_Control.transform.GetComponentsInChildren(true).ToList().ForEach(a => a.Awake()); } public void SwitchFirstPersonControllerMove(bool isMove) { firstPersonController.playerCanMove = isMove; } /// /// /// /// /// /// 是否设置FOV 和 上下视角 public void SetFirstPersonTransform(Vector3 _pos, Vector3 _angle, bool isSetFOVAndUpDownView = false, float fov = 0, Vector3 _camareAngle = new Vector3(), bool isRecord = false) { if (isRecord) { lastPlayerPos = firstPersonController.transform.position; lastPlayerAngle = firstPersonController.transform.eulerAngles; lastFOV = firstPersonController.playerCamera.fieldOfView; lastPlayerCameraAngle = firstPersonController.playerCamera.transform.localEulerAngles; } firstPersonController.transform.position = _pos; firstPersonController.transform.eulerAngles = _angle; if (isSetFOVAndUpDownView) { firstPersonController.playerCamera.fieldOfView = fov; firstPersonController.playerCamera.transform.localEulerAngles = _camareAngle; } firstPersonController.yaw = 0; firstPersonController.pitch = 0; } public void ResetFirstPersonTransform() { if (lastFOV != 0) { firstPersonController.transform.position = lastPlayerPos; firstPersonController.transform.eulerAngles = lastPlayerAngle; firstPersonController.playerCamera.fieldOfView = lastFOV; firstPersonController.playerCamera.transform.localEulerAngles = lastPlayerCameraAngle; firstPersonController.yaw = 0; firstPersonController.pitch = 0; } } //private void OnZoom(float value) //{ // tMDTips.localScale = new Vector3(value, value, value); //} public void SetSpawnToolInfo(GameObject tool) { if (tool == null) return; currentTool = tool; currentTool.transform.parent = Camera.main.transform; currentTool.transform.localPosition = spawnToolPos.localPosition; currentTool.transform.localEulerAngles = spawnToolPos.localEulerAngles; if (currentTool.GetComponent()) { currentTool.GetComponent().SetHeadPosAndEulerang(currentTool.transform.localPosition, currentTool.transform.localEulerAngles); } } private void Update() { if (Input.GetKeyDown(KeyCode.Escape)) { if (currentTool != null) { Debug.Log("Escape"); OnCheckSubProcess(); } } } public void OnCheckSubProcess(bool ifdestroy = true) { if (currentTool != null) { if (ifdestroy) DestroyImmediate(currentTool); currentTool = null; } } private void OnDestroy() { currentTool = null; Debug.Log("LiveSceneManager OnDestroy"); } private void OnDisable() { Debug.Log(" OnDisable()"); } }