using System.Collections; using System.Collections.Generic; using BigSpace.Logic; using BigSpace.XRCore.Event; using BigSpace.XRCore.RunningScene; using Unity.XR.PXR; using UnityEngine; using static Unity.VisualScripting.Member; using UnityEngine.UIElements; public class PlayJiaGuAnimator : MonoBehaviour { public List listAnimator; public GameObject handObj; public int HandType; public HandFontSelfCtr font; public GameObject catchJiaGu; public GameObject animatorJiaGu; public AudioSource audio_HuiDa; public GameObject audio_Wen; //控制文字显示时机 bool oneIsRun = false; float oneWaitTime = 26f; float oneRunTime = 0; // Start is called before the first frame update void Start() { GlobalEventMgr.Listen(GameEvent.EventHideTuchJiaGu, GameDataManage_EventHideTuchJiaGu); } private void Update() { if (oneIsRun) { oneRunTime += Time.deltaTime; if (oneRunTime >= oneWaitTime) { oneIsRun = false; oneRunTime = 0; if (font != null) //显示字 font.PlayShowJGWFont(); if (animatorJiaGu != null) animatorJiaGu.SetActive(false); if (catchJiaGu != null) catchJiaGu.SetActive(true); } } } [Header("动画控制")] [SerializeField] private List childAnimator; // 直接拖动绑定 public void SetTriggerParameter(string parameterName) { for (int i = 0; i < childAnimator.Count; i++) { Destroy(childAnimator[i]); } } private void OnTriggerEnter(Collider other) { if (other.gameObject.name == "PalmBox_L" || other.gameObject.name == "PalmBox_R") { if (listAnimator != null) { SetTriggerParameter("DisTrigger"); for (int i = 0; i < listAnimator.Count; i++) { if (HandType == 1) { listAnimator[i].Play("shaohuo_L"); } else { listAnimator[i].Play("shaohuo_R"); } } } oneIsRun = true; GlobalEventMgr.Dispatch(GameEvent.EventHideTuchJiaGu); //只能摸一次,关闭所有的可触摸甲骨碰撞 if (audio_HuiDa != null) { audio_HuiDa.Play(); } } } void GameDataManage_EventHideTuchJiaGu() { this.GetComponent().enabled = false; if (handObj != null) { handObj.SetActive(false); } if (audio_Wen != null) audio_Wen.SetActive(false); } }