using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.EventSystems; /// /// 安全帽门 /// public class SafetyHelmetDoor : MonoBehaviour { public bool isOpen; public Animator animator; // Start is called before the first frame update void Start() { animator = GetComponent(); } private void OnMouseDown() { if (EventSystem.current.IsPointerOverGameObject())//鼠标在UI上 return; isOpen = !isOpen; //获取Animator组件 改变动画状态IsOpen animator.SetBool("IsOpen", isOpen); } }