添加委托以在将反射探针添加到场景或从场景中移除时获取通知。
using UnityEngine; using UnityEngine.Rendering;
public class ReflectionProbeManager : MonoBehaviour { private static void OnReflectionProbeEvent(ReflectionProbe probe, ReflectionProbe.ReflectionProbeEvent eventType) { Debug.Log("A ReflectionProbe event has occured: " + eventType); }
void Start() { ReflectionProbe.reflectionProbeChanged += OnReflectionProbeEvent; }
void OnDestroy() { ReflectionProbe.reflectionProbeChanged -= OnReflectionProbeEvent; } }