using System.Collections; using System.Collections.Generic; using UnityEngine; /* 让箭发光(用于标记最新射出的一支箭) */ public class ArrowLightSick : MonoBehaviour { [SerializeField] Material[] defaultMats; [SerializeField] Material lightSickMat; static HashSet set = new HashSet(); void Start() { set.Add(this); } void OnDestroy() { set.Remove(this); } public void Hit() { MeshRenderer mr = this.GetComponent(); Material[] mats = mr.materials; mats[1] = lightSickMat; mr.materials = mats; } void Recovery() { MeshRenderer mr = this.GetComponent(); mr.materials = defaultMats; } public static void RecoveryAll() { foreach (var item in set) { item.Recovery(); } } }