using HighlightingSystem; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Events; using UnityEngine.EventSystems; using UnityEngine.SceneManagement; //============================================================ //支持中文,文件使用UTF-8编码 //@author #AUTHOR# //@create #CREATEDATE# //@company #COMPANY# // //@description: //============================================================ public enum Attribute { /// /// 默认 /// defaultModel, /// /// 安全工器具 /// SafetyToolsAndInstruments, /// /// 工器具 /// ToolsAndInstruments } public enum RightAndWrong { /// /// 默认 /// defaultModel, /// /// 对 /// right, /// /// 错 /// wrong } public enum WearAndUse { /// /// 默认 /// defaultModel, /// /// 穿戴 /// wear, /// /// 使用 /// use } public class ToolModelClick : MonoBehaviour { public Attribute attribute = Attribute.defaultModel; public RightAndWrong rightAndWrong = RightAndWrong.defaultModel; public WearAndUse wearAnduse = WearAndUse.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; public Highlighter selfHighlighter; private void Awake() { if (line != null) line.SetActive(false); if (Higth != null) { Higth.SetActive(false); } selfHighlighter = GetComponent(); selfHighlighter.ConstantOff(); } private void OnMouseEnter() { if (EventSystem.current.IsPointerOverGameObject()) return; onEnter?.Invoke(); var current = SceneManager.GetActiveScene(); if (current.name == "工具间场景") UIManager.Instance.SetThreeDTip(gameObject, Input.mousePosition); } private void OnMouseDown() { if (EventSystem.current.IsPointerOverGameObject()) return; var current = SceneManager.GetActiveScene(); if (current.name != "工具间场景") return; onDown?.Invoke(); Vector3 pos = transform.localPosition; Vector3 rot = transform.localEulerAngles; ToolsItemManager.Instance.CreatToolItem(gameObject, pos, rot); UIManager.Instance.SetThreeDTip(null, Vector3.zero); Destroy(gameObject); } private void OnMouseDrag() { if (EventSystem.current.IsPointerOverGameObject()) return; onDrag?.Invoke(); } private void OnMouseExit() { UIManager.Instance.SetThreeDTip(null, Vector3.zero); if (EventSystem.current.IsPointerOverGameObject()) return; var current = SceneManager.GetActiveScene(); if (current.name != "工具间场景") return; onExit?.Invoke(); } }