Version: 2019.2
可编程渲染管线 SRP Batcher
物理系统

Light Explorer 扩展

The Light Explorer extension allows you to create your own version of the Light Explorer window. This window is a powerful visualization and editing tool that you can use to see every Light in your Scene and edit their properties. With this extension, you can extend the current window in multiple ways. For example, you can:

  • 更改选项卡(从简单地更改选项卡名称到添加您自己的自定义选项卡)以显示不同类型的游戏对象的列表。例如,如果要显示自己的自定义反射探针的属性信息,这将很有用。
  • 更改选项卡上的列(同样从更改名称到添加您自己的自定义列)。如果要查看其他光源属性,添加列很有用。

Use this extension to create a Light Explorer within your own custom Scriptable Render Pipeline (SRP), or with the High Definition Render Pipeline’s custom Lights.

扩展 Light Explorer

要扩展 Light Explorer,可以继承自:

  • ILightingExplorerExtension 接口,然后覆盖 GetContentTabs 方法。
  • DefaultLightingExplorerExtension 类(继承自 ILightingExplorerExtension)。此类提供窗口中已经存在的所有内容。如果只希望覆盖选项卡的数量、每个选项卡的标题或要显示的光源,请使用此选项。要了解如何以这种方式扩展 Light Explorer,请参阅下面的示例。

示例代码

本节中的示例展示了如何扩展默认的 Light Explorer 类以仅显示光源的名称 (Name) 列,以及如何更改选项卡的数量。在您自己的实现中,可以根据需要覆盖任意数量的方法。

以下示例显示了光源的名称列:

namespace UnityEditor
{
    [LightingExplorerExtensionAttribute(typeof(SomeRenderPipelineAsset))]
    public class SimpleExplorerExtension : DefaultLightingExplorerExtension
    {
        protected override LightingExplorerTableColumn[] GetLightColumns()
        {
            return new[]
            {
                new LightingExplorerTableColumn(LightingExplorerTableColumn.DataType.Name, Styles.Name, null, 200), // 0:名称
            }
        }
    }
}

以下示例仅显示光源的名称和启用状态,并隐藏 Emissive Materials 选项卡(仅显示 3 个选项卡,而不是 4 个)

namespace UnityEditor
{
    [LightingExplorerExtensionAttribute(typeof(SomeOtherRenderPipelineAsset))]
    public class ComplexLightExplorerExtension : DefaultLightingExplorerExtension
    {
       protected virtual UnityEngine.Object[] GetLights()
        {
            return Resources.FindObjectsOfTypeAll<Light>();
        }

        protected virtual LightingExplorerTableColumn[] GetLightColumns()
        {
            return new[]
            {
                new LightingExplorerTableColumn(LightingExplorerTableColumn.DataType.Name, Styles.Name, null, 200), // 0:名称
                new LightingExplorerTableColumn(LightingExplorerTableColumn.DataType.Checkbox, Styles.On, "m_Enabled", 25), // 1:已启用
            {
        {

        public virtual LightingExplorerTab[] GetContentTabs()
        {
            return new[]
            {
                new LightingExplorerTab("Light Table", GetLights, GetLightColumns),
                new LightingExplorerTab("Reflection Probes", GetReflectionProbes, GetReflectionProbeColumns),
                new LightingExplorerTab("Light Probes", GetLightProbes, GetLightProbeColumns)            };
        }
    }
}

有用的类和方法

下面列出了可用于扩展 Light Explorer 的类和方法:

ILightingExplorerExtension:

public virtual LightingExplorerTab[] GetContentTabs();
public virtual void OnEnable() {}
public virtual void OnDisable() {}

DefaultLightingExplorerExtension(继承自 ILightingExplorerExtension):

public virtual LightingExplorerTab[] GetContentTabs();
public virtual void OnEnable() {}
public virtual void OnDisable() {}

protected virtual UnityEngine.Object[] GetLights();
protected virtual LightingExplorerTableColumn[] GetLightColumns();

protected virtual UnityEngine.Object[] GetReflectionProbes();
protected virtual LightingExplorerTableColumn[] GetReflectionProbeColumns();

protected virtual UnityEngine.Object[] GetLightProbes();
protected virtual LightingExplorerTableColumn[] GetLightProbeColumns();

protected virtual UnityEngine.Object[] GetEmissives();
protected virtual LightingExplorerTableColumn[] GetEmissivesColumns();

  • 2019–08–13 页面已发布
  • 2018.3 中添加了 Light Explorer 扩展 NewIn20183
可编程渲染管线 SRP Batcher
物理系统