using System; using System.Collections; using System.Collections.Generic; using DefaultNamespace.ProcessMode; using HighlightPlus; using MotionFramework; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.UI; /// /// 镜子管理器 /// public class CharacterMirrorManager : MonoBehaviour { [SerializeField] private GameObject text; [SerializeField] private Image uiImage; [SerializeField] private GameObject window; private void OnMouseEnter() { text.SetActive(true); this.GetComponent().highlighted = true; } private void OnMouseExit() { text.SetActive(false); this.GetComponent().highlighted = false; } private void OnMouseDown() { if(EventSystem.current.IsPointerOverGameObject()) return; MotionEngine.GetModule().HandleClick(this.gameObject.name); StartCoroutine(FadeIn(uiImage, 0.5f)); } private IEnumerator FadeIn(Image image, float duration) { image.gameObject.SetActive(true); // 初始化透明度为0 Color color = image.color; color.a = 0f; image.color = color; float elapsedTime = 0f; // 渐变透明度 while (elapsedTime < duration) { elapsedTime += Time.deltaTime; color.a = Mathf.Clamp01(elapsedTime / duration); image.color = color; yield return null; } // 确保透明度设置为1 color.a = 1f; image.color = color; image.raycastTarget = true; window.SetActive(true); } }