using UnityEngine; public class Point2ClickHandler : MonoBehaviour { public GameObject nextObject; // This will be Shose private bool _clicked; public bool CanBeClicked() { return !_clicked; } private MeshRenderer _meshRenderer; private void OnDisable() { StopAllCoroutines(); if (_meshRenderer != null) _meshRenderer.enabled = false; } void OnEnable() { if (GetComponent() == null) gameObject.AddComponent().radius = 0.5f; _meshRenderer = GetComponent(); if (_meshRenderer != null) { _meshRenderer.enabled = true; var mat = _meshRenderer.material; if (mat != null && mat.HasProperty("_MainColor")) { var c = mat.GetColor("_MainColor"); c.a = 0f; mat.SetColor("_MainColor", c); if (mat.HasProperty("_OutlineWidth")) { mat.SetFloat("_OutlineWidth", OutlineConfig.Width); } } } _clicked = false; StopAllCoroutines(); bool isExam = GameManager.Instance != null && GameManager.Instance.CurrentMode == ExperimentMode.Exam; if (!isExam) { StartCoroutine(BlinkOutline()); } } System.Collections.IEnumerator BlinkOutline() { yield return new WaitForSeconds(0.4f); while (true) { if (_meshRenderer != null) _meshRenderer.enabled = !_meshRenderer.enabled; yield return new WaitForSeconds(0.4f); } } void OnMouseDown() { PerformClick(); } public void PerformClick() { if (_clicked) return; _clicked = true; Debug.Log("[Point2Click] ★ 被点击 ★"); ActionHistory.Push(ActionHistory.ActionType.Point2, this); var examMgr = FindObjectOfType(); if (examMgr != null) examMgr.OnObjectClicked(this); StopAllCoroutines(); if (_meshRenderer != null) _meshRenderer.enabled = false; var woman = GameObject.Find("woman"); if (woman != null) { var anim = woman.GetComponent(); if (anim != null) { anim.SetBool("IsCheck", true); } } // 播放语音 var am = FindObjectOfType(); if (am != null) { #if UNITY_EDITOR var fractureClip = UnityEditor.AssetDatabase.LoadAssetAtPath("Assets/Audio/people/伤员左大腿疑似骨折,无伤口.mp3"); if (fractureClip != null) am.PlayVoice(fractureClip); #endif } if (nextObject != null) { var shoseHandler = nextObject.GetComponent(); if (shoseHandler != null) shoseHandler.enabled = true; else nextObject.SetActive(true); } gameObject.SetActive(false); } public void ResetState() { ResetState(true); } public void ResetState(bool startBlink) { _clicked = false; if (_meshRenderer != null) _meshRenderer.enabled = startBlink; if (nextObject != null) { var shoseHandler = nextObject.GetComponent(); if (shoseHandler != null) shoseHandler.enabled = false; else nextObject.SetActive(false); } var woman = GameObject.Find("woman"); if (woman != null) { var anim = woman.GetComponent(); if (anim != null) { anim.SetBool("IsCheck", false); } } StopAllCoroutines(); gameObject.SetActive(startBlink); bool isExam = GameManager.Instance != null && GameManager.Instance.CurrentMode == ExperimentMode.Exam; if (startBlink && isActiveAndEnabled && !isExam) { StartCoroutine(BlinkOutline()); } } }