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