using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using DG.Tweening; /// /// 叉车屏幕控制(场景跳转、视频播放) /// public class ForkliftScreenController : MonoBehaviour { [Header("模式界面")] public GameObject[] AllRawImage; public Button CZMNBtn; //模拟操作按钮 public Button SGMNBtn; //事故模拟按钮 public Button SGAlBtn; //事故案例按钮 [Header("事故案例返回按钮")] public Button SGANRetrueBtn; //事故案例返回按钮 [Header("叉车操作模拟")] public GameObject CCCZMNCanvas; public Button CCCZMNBtn; //叉车模拟返回按钮 public GameObject CCMNAllObj; //叉车模拟所有物体 [Header("叉车事故模拟-撞车")] public GameObject SGMNMNCanvas; //模拟事故界面 public Button SGMNMNRetrueBtn; //模拟事故返回按钮 public Animator[] mnsgcar; public GameObject SGMNCar_AllObj; //模拟事故-车所有物体 public Button[] SGYbTN; //事故右上角按钮 public Texture[] SGTexture; //事故画面 [Header("叉车事故模拟-撞人")] public Transform person; //被撞人 public Transform Forklift; //叉车 // public Animator[] mnsg_person; // public GameObject zhaungche; private void Awake() { Init(); } public void Init() { for (int i = 0; i < AllRawImage.Length; i++) { AllRawImage[i].SetActive(i == 0); } for (int i = 0; i < mnsgcar.Length; i++) { mnsgcar[i].speed = 0; } SGMNCar_AllObj.SetActive(false); } void Start() { CZMNBtn.onClick.AddListener(() => { Debug.Log("CZMNBtn"); for (int i = 0; i < AllRawImage.Length; i++) { AllRawImage[i].SetActive(i == 1); } CCCZMNCanvas.SetActive(true); CCMNAllObj.SetActive(true); SGMNCar_AllObj.SetActive(false); }); SGMNBtn.onClick.AddListener(() => { Debug.Log("SGMNBtn"); for (int i = 0; i < AllRawImage.Length; i++) { AllRawImage[i].SetActive(i == 2); } }); SGAlBtn.onClick.AddListener(() => { Debug.Log("SGAlBtn"); for (int i = 0; i < AllRawImage.Length; i++) { AllRawImage[i].SetActive(i == 3); } }); //事故案例返回按钮 SGANRetrueBtn.onClick.AddListener(() => { Debug.Log("事故案例返回按钮"); for (int i = 0; i < AllRawImage.Length; i++) { AllRawImage[i].SetActive(i == 0); } }); //叉车模拟返回按钮 CCCZMNBtn.onClick.AddListener(() => { Debug.Log("叉车模拟返回按钮"); for (int i = 0; i < AllRawImage.Length; i++) { AllRawImage[i].SetActive(i == 0); } CCCZMNCanvas.SetActive(false); CCMNAllObj.SetActive(false); }); //模拟事故事故一按钮 SGYbTN[0].onClick.AddListener(() => { RawImage rawImage0 = AllRawImage[2].GetComponent(); if (rawImage0 == null) { Debug.Log("rawImage0为null"); } else { rawImage0.texture = SGTexture[0]; for (int i = 0; i < mnsgcar.Length; i++) { mnsgcar[i].speed = 1; } SGMNMNCanvas.SetActive(true); SGMNCar_AllObj.SetActive(true); Debug.Log("事故一"); } }); //模拟事故事故二按钮 SGYbTN[1].onClick.AddListener(() => { RawImage rawImage1 = AllRawImage[2].GetComponent(); if (rawImage1 == null) { Debug.Log("rawImage1为null"); } else { rawImage1.texture = SGTexture[1]; Forklift.transform.DOMove(new Vector3(823.72f,9.48f,343.11f), 4f); person.transform.DOMove(new Vector3(823.58f,9.493f,341.27f), 5f); Debug.Log("事故二"); } }); //模拟事故返回按钮 SGMNMNRetrueBtn.onClick.AddListener(() => { Debug.Log("模拟事故返回按钮"); for (int i = 0; i < AllRawImage.Length; i++) { AllRawImage[i].SetActive(i == 0); } SGMNMNCanvas.SetActive(false); }); } // public void ObjMove(GameObject moveObj,float speed, Vector3 objPos) // { // moveObj.transform.Translate(Vector3.forward * speed * Time.deltaTime); // } }