using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Events; using UnityEngine.EventSystems; //============================================================ //支持中文,文件使用UTF-8编码 //@author #AUTHOR# //@create #CREATEDATE# //@company #COMPANY# // //@description: //============================================================ public enum Attribute { /// /// 默认 /// defaultModel, /// /// 安全工器具 /// SafetyToolsAndInstruments, /// /// 工器具 /// ToolsAndInstruments } public enum RightAndWrong { /// /// 默认 /// defaultModel, /// /// 对 /// right, /// /// 错 /// wrong } public class ToolModelClick : MonoBehaviour { public Attribute attribute = Attribute.defaultModel; public RightAndWrong rightAndWrong = RightAndWrong.defaultModel; public UnityEvent onEnter = new UnityEvent(); public UnityEvent onDown = new UnityEvent(); public UnityEvent onDrag = new UnityEvent(); public UnityEvent onExit = new UnityEvent(); public GameObject line; public GameObject Higth; private void Awake() { if (line != null) line.SetActive(false); if (Higth!=null) { Higth.SetActive(false); } } private void OnMouseEnter() { if (EventSystem.current.IsPointerOverGameObject()) return; onEnter?.Invoke(); } private void OnMouseDown() { if (EventSystem.current.IsPointerOverGameObject()) return; onDown?.Invoke(); ToolsItemManager.Instance.CreatToolItem(gameObject); Destroy(gameObject); } private void OnMouseDrag() { if (EventSystem.current.IsPointerOverGameObject()) return; onDrag?.Invoke(); } private void OnMouseExit() { if (EventSystem.current.IsPointerOverGameObject()) return; onExit?.Invoke(); } }