反射探针用于将周围环境捕获为纹理,纹理将传递给着色器并用于反射。
属性与 Inspector 中显示的值完全匹配。
此类是 reflection probe 组件的脚本接口。
通常只在 Editor 中创建反射探针,但有时需要从脚本创建反射探针:
using UnityEngine; using UnityEditor;
public class ProbeCreator { [MenuItem("ReflectionProbe/CreateRealtimeProbe")] public static void RealtimeProbe() { // Add a GameObject with a ReflectionProbe component GameObject probeGameObject = new GameObject("Realtime Reflection Probe"); ReflectionProbe probeComponent = probeGameObject.AddComponent<ReflectionProbe>(); // The probe will contribute to reflections inside a box of size 10x10x10 centered on the position of the probe probeComponent.size = new Vector3(10, 10, 10);
// Set the type to realtime and refresh the probe every frame probeComponent.mode = UnityEngine.Rendering.ReflectionProbeMode.Realtime; probeComponent.refreshMode = UnityEngine.Rendering.ReflectionProbeRefreshMode.EveryFrame; } }
defaultTexture | The surface texture of the default reflection probe that captures the environment contribution. Read only. |
defaultTextureHDRDecodeValues | 默认反射探针纹理的 HDR 解码值。 |
backgroundColor | 用于清除反射探针纹理的颜色。 |
bakedTexture | 引用反射探针周围环境的烘焙纹理。 |
blendDistance | 用于混合的探针周围距离(在延迟探针中使用)。 |
bounds | The probe's world space axis-aligned bounding box in which the probe can contribute to reflections (Read Only). |
boxProjection | 此反射探针是否应使用盒体投影。 |
center | The center of the probe's bounding box in which the probe can contribute to reflections. The center is relative to the position of the probe. |
clearFlags | 反射探针清除背景的方式。 |
cullingMask | 用于选择性地渲染反射探针周围的某些部分。 |
customBakedTexture | 引用反射探针周围环境的烘焙纹理。使用此变量可分配自定义反射纹理。 |
farClipPlane | 渲染探针时的远裁剪面距离。 |
hdr | 此反射探针是否应使用 HDR 渲染? |
importance | 反射探针重要性。 |
intensity | 在着色器中应用于反射探针纹理的强度修改器。 |
mode | 应在 Editor 中生成反射探针纹理 (ReflectionProbeMode.Baked) 还是探针应使用自定义指定纹理 (ReflectionProbeMode.Custom)? |
nearClipPlane | 渲染探针时的近裁剪面距离。 |
realtimeTexture | Reference to the real-time texture of the reflection probe's surroundings. Use this to assign a RenderTexture to use for real-time reflection. |
refreshMode | 设置探针的刷新方式。另请参阅:ReflectionProbeRefreshMode。 |
renderDynamicObjects | Specifies whether Unity should render non-static GameObjects into the Reflection Probe. If you set this to true, Unity renders non-static GameObjects into the Reflection Probe. If you set this to false, Unity does not render non-static GameObjects into the Reflection Probe. Unity only takes this property into account if the Reflection Probe's Type is Custom. |
resolution | 底层反射纹理的分辨率(以像素为单位)。 |
shadowDistance | 渲染探针时的阴影绘制距离。 |
size | The size of the probe's bounding box in which the probe can contribute to reflections. The size is in world space. |
texture | 传递给反射探针邻近对象的着色器的纹理。 |
textureHDRDecodeValues | 反射探针纹理的 HDR 解码值。 |
timeSlicingMode | 将此探针设置为时间切片模式另请参阅:ReflectionProbeTimeSlicingMode。 |
IsFinishedRendering | 检查探针是否已完成时间切片渲染。 |
RenderProbe | 刷新探针的立方体贴图。 |
Reset | 将所有 ReflectionProbe 参数恢复为默认值。 |
BlendCubemap | Utility 方法,将两个立方体贴图混合到一个目标渲染纹理中。 |
UpdateCachedState | Updates the culling system with the ReflectionProbe's current state. This ensures that Unity correctly culls the ReflectionProbe during rendering if you implement your own runtime reflection system. |
defaultReflectionSet | 添加委托以在默认镜面立方体贴图发生变化时收到通知。 |
defaultReflectionTexture | 添加委托以在默认镜面立方体贴图发生变化时收到通知。 |
reflectionProbeChanged | 添加委托以在将反射探针添加到场景或将其从场景中删除时收到通知。 |
enabled | 启用的 Behaviour 可更新,禁用的 Behaviour 不可更新。 |
isActiveAndEnabled | Reports whether a GameObject and its associated Behaviour is active and enabled. |
gameObject | 此组件附加到的游戏对象。始终将组件附加到游戏对象。 |
tag | 此游戏对象的标签。 |
transform | 附加到此 GameObject 的 Transform。 |
hideFlags | 该对象应该隐藏、随场景一起保存还是由用户修改? |
name | 对象的名称。 |
BroadcastMessage | 调用此游戏对象或其任何子项中的每个 MonoBehaviour 上名为 methodName 的方法。 |
CompareTag | Checks the GameObject's tag against the defined tag. |
GetComponent | Gets a reference to a component of type T on the same GameObject as the component specified. |
GetComponentInChildren | Gets a reference to a component of type T on the same GameObject as the component specified, or any child of the GameObject. |
GetComponentInParent | Gets a reference to a component of type T on the same GameObject as the component specified, or any parent of the GameObject. |
GetComponents | Gets references to all components of type T on the same GameObject as the component specified. |
GetComponentsInChildren | Gets references to all components of type T on the same GameObject as the component specified, and any child of the GameObject. |
GetComponentsInParent | Gets references to all components of type T on the same GameObject as the component specified, and any parent of the GameObject. |
SendMessage | 调用此游戏对象中的每个 MonoBehaviour 上名为 methodName 的方法。 |
SendMessageUpwards | 调用此游戏对象中的每个 MonoBehaviour 上或此行为的每个父级上名为 methodName 的方法。 |
TryGetComponent | 获取指定类型的组件(如果存在)。 |
GetInstanceID | Gets the instance ID of the object. |
ToString | 返回对象的名称。 |
Destroy | 移除 GameObject、组件或资源。 |
DestroyImmediate | 立即销毁对象 /obj/。强烈建议您改用 Destroy。 |
DontDestroyOnLoad | 在加载新的 Scene 时,请勿销毁 Object。 |
FindAnyObjectByType | Retrieves any active loaded object of Type type. |
FindFirstObjectByType | Retrieves the first active loaded object of Type type. |
FindObjectsByType | Retrieves a list of all loaded objects of Type type. |
Instantiate | 克隆 original 对象并返回克隆对象。 |
bool | 该对象是否存在? |
operator != | 比较两个对象是否引用不同的对象。 |
operator == | 比较两个对象引用,判断它们是否引用同一个对象。 |