using DG.Tweening; using System.Collections; using UnityEngine; using UnityEngine.UI; public class CameraManager : MonoBehaviour { public static CameraManager instance; public Camera Camera; /// /// 所有的种子 /// public GameObject[] seed_Obj; public Transform[] StepTrans; public GameObject SeedWater_Obj; public GameObject water_Obj; private void Awake() { instance = this; } private void Update() { if (Input.GetMouseButtonDown(0)) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; bool raycast = Physics.Raycast(ray, out hit); if (raycast) { if (hit.collider.gameObject.tag.Equals("CompleteSeeds")) { Debug.Log("被点击物体的标签是" + hit.collider.gameObject.tag); hit.collider.gameObject.SetActive(false); bool allSeedsHidden = true; for (int i = 0; i < seed_Obj.Length; i++) { if (seed_Obj[i].activeInHierarchy) { allSeedsHidden = false; Debug.Log("还有种子没有点到"); break; // 只要有一个种子没隐藏,就退出循环 } } // 检查是否所有种子都被隐藏(放在循环外) if (allSeedsHidden) { Debug.Log("所有种子都被隐藏"); Camera.fieldOfView = 60; StartCoroutine(SeedIsFalse()); } } } } } public IEnumerator SeedIsFalse() { Camera.transform.SetPositionAndRotation (StepTrans[2].transform.position, StepTrans[1].transform.rotation); yield return new WaitForSeconds(1f); SeedWater_Obj.transform.DOMoveY(0, 1f); yield return new WaitForSeconds(2.1f); water_Obj.transform.DOMoveY(0.1f, 1.5f); yield return new WaitForSeconds(2.5f); UI_FadePanel.Instance.Init(); yield return new WaitForSeconds(9f); UI_FadePanel.Instance.Next_Btn.gameObject.SetActive(true); } }