Tz2/Assets/Zion/Scripts/SafetyHelmetDoor.cs

28 lines
657 B
C#

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