using System.Collections.Generic; using UnityEngine; public class EffectManager : MonoBehaviour { public static EffectManager Ins; public List curEffects = new List(); [Header("正确特效")] public GameObject correctEffectPrefab; // 正确特效(发光圈、闪光) public GameObject correctCirclePrefab; // 正确圈中提示 [Header("错误特效")] public GameObject wrongEffectPrefab; // 错误特效(红叉、火花) private void Awake() { Ins = this; } // ✅ 正确圈中特效 public void ShowCorrectCircle(Transform parent) { if (correctCirclePrefab == null) { Debug.LogWarning("未设置 CorrectCirclePrefab"); return; } GameObject obj = Instantiate(correctCirclePrefab,parent); obj.GetComponent().localPosition = Vector3.zero; curEffects.Add(obj); } // ✅ 正确点击闪光特效 public void ShowCorrectEffect(Vector3 worldPos) { if (correctEffectPrefab == null) { Debug.LogWarning("未设置 CorrectEffectPrefab"); return; } GameObject obj = Instantiate(correctEffectPrefab, worldPos, Quaternion.identity); Destroy(obj, 2f); } // ✅ 错误点击特效 public void ShowWrongEffect(Vector2 uiLocalPos, Transform parent) { GameObject obj = Instantiate(wrongEffectPrefab, parent); RectTransform rt = obj.GetComponent(); rt.anchoredPosition = uiLocalPos; // ✅ 不是 localPosition Destroy(obj, 4f); } public void PlayBronzeLinkLight() { foreach (var block in FindObjectsOfType()) { var mat = block.GetComponent().material; mat.SetFloat("_Glow", 1); } } public void CloseEffectList() { foreach (var obj in curEffects) { Destroy(obj); } curEffects.Clear(); } }