包含此页的版本:
不含此页的版本:
Light Explorer 扩展允许您创建自己的 Light Explorer 窗口版本。你可以使用它来调整 光源资源管理器(Light Explorer) 窗口的功能,以便它与自定义的可脚本对象一起使用渲染管线(Render Pipeline) 获取场景内容并将其显示在屏幕上的一系列作。Unity 允许您从预构建的渲染管道中进行选择,或编写自己的渲染管道。更多信息
请参阅术语表(SRP),或使用高清渲染管线的自定义光源。
光源资源管理器窗口可让您查看场景场景包含游戏的环境和菜单。将每个唯一的场景文件视为一个独特的关卡。在每个场景中,你放置你的环境、障碍物和装饰品,基本上是将你的游戏设计和构建成碎片。更多信息
请参阅术语表并编辑其属性。使用此扩展,您可以通过多种方式扩展当前窗口。例如,您可以:
要扩展光源浏览器,可以继承自:
ILightingExplorerExtension接口并覆盖GetContentTabs方法。DefaultLightingExplorerExtension类,继承自ILightingExplorerExtension.此类为您提供窗口中已有的所有内容。如果只想覆盖选项卡的数量、每个选项卡的标题或要显示的光源,请使用此选项。要了解如何以这种方式扩展光源浏览器,请参阅以下示例。本节中的示例将介绍如何扩展默认的光源资源管理器类,以仅显示光源的 名称(Name) 列,并更改选项卡数。在您自己的实现中,您可以根据需要覆盖任意数量的方法。
以下示例仅显示光源的名称列:
using UnityEngine;
using UnityEngine.Rendering;
using UnityEditor;
[SupportedOnRenderPipeline(typeof(ExampleRenderPipelineAsset))]
public class SimpleExplorerExtension : DefaultLightingExplorerExtension
{
private static class Styles
{
public static readonly GUIContent Name = EditorGUIUtility.TrTextContent("Name");
}
protected override LightingExplorerTableColumn[] GetLightColumns()
{
return new[]
{
new LightingExplorerTableColumn(LightingExplorerTableColumn.DataType.Name, Styles.Name, null, 200), // 0: Name
};
}
}
以下示例仅显示光源的名称和启用状态,并隐藏 自发光材质(Emissive Materials) 选项卡(仅显示3个选项卡,而不是4个)
using UnityEngine;
using UnityEngine.Rendering;
using UnityEditor;
[SupportedOnRenderPipeline(typeof(ExampleRenderPipelineAsset))]
public class ComplexLightExplorerExtension : DefaultLightingExplorerExtension
{
private static class Styles
{
public static readonly GUIContent Name = EditorGUIUtility.TrTextContent("Name");
public static readonly GUIContent Enabled = EditorGUIUtility.TrTextContent("Enabled");
}
protected override UnityEngine.Object[] GetLights()
{
return Resources.FindObjectsOfTypeAll<Light>();
}
protected override LightingExplorerTableColumn[] GetLightColumns()
{
return new[]
{
new LightingExplorerTableColumn(LightingExplorerTableColumn.DataType.Name, Styles.Name, null, 200), // 0: Name
new LightingExplorerTableColumn(LightingExplorerTableColumn.DataType.Checkbox, Styles.Enabled, "m_Enabled", 25), // 1: Enabled
};
}
public override LightingExplorerTab[] GetContentTabs()
{
return new[]
{
new LightingExplorerTab("Lights", GetLights, GetLightColumns, true),
new LightingExplorerTab("2D Lights", Get2DLights, Get2DLightColumns, true),
new LightingExplorerTab("Reflection Probes", GetReflectionProbes, GetReflectionProbeColumns, true),
new LightingExplorerTab("Light Probes", GetLightProbes, GetLightProbeColumns, true),
new LightingExplorerTab("Static Emissives", GetEmissives, GetEmissivesColumns, false),
};
}
}
下面是可用于扩展光源资源管理器的类和方法的列表:
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();