using System.Collections.Generic; namespace UnityEngine.Rendering.HighDefinition { /// /// Additional component used to store settings for HDRP's reflection probes. /// [HDRPHelpURLAttribute("Reflection-Probe")] [AddComponentMenu("")] // Hide in menu [DisallowMultipleComponent] [RequireComponent(typeof(ReflectionProbe))] public sealed partial class HDAdditionalReflectionData : HDProbe, IAdditionalData { static readonly HashSet s_AllInstances = new HashSet(); void Awake() { type = ProbeSettings.ProbeType.ReflectionProbe; k_ReflectionProbeMigration.Migrate(this); s_AllInstances.Add(this); } void OnDestroy() { s_AllInstances.Remove(this); } /// /// Returns the currently instantiated reflection data. /// /// /// Note: A temporary array is created to return the results. /// Note: The returned reflection data is independent of whether it is disabled or not. /// /// /// An array of collected reflection data. /// public static HDAdditionalReflectionData[] GetAllInstances() { HDAdditionalReflectionData[] reflectionDatas = new HDAdditionalReflectionData[s_AllInstances.Count]; s_AllInstances.CopyTo(reflectionDatas, 0); return reflectionDatas; } } /// /// Utilities for reflection probes. /// public static class HDAdditionalReflectionDataExtensions { /// /// Requests that Unity renders the passed in Reflection Probe during the next update. /// /// /// If you call this method for a Reflection Probe using mode, Unity renders the probe the next time the probe influences a Camera rendering. /// /// If the Reflection Probe doesn't have an attached component, calling this function has no effect. /// /// Note: If any part of a Camera's frustum intersects a Reflection Probe's influence volume, the Reflection Probe influences the Camera. /// /// The Reflection Probe to request a render for. public static void RequestRenderNextUpdate(this ReflectionProbe probe) { var add = probe.GetComponent(); if (add != null && !add.Equals(null)) add.RequestRenderNextUpdate(); } } }