浏览代码

[HDCameraEditor] Refactored UI Framework

/main
Frédéric Vauchelles 7 年前
当前提交
3a51c9b2
共有 29 个文件被更改,包括 368 次插入352 次删除
  1. 21
      ScriptableRenderPipeline/Core/CoreRP/Editor/CoreEditorDrawers.cs
  2. 6
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/HDCameraEditor.cs
  3. 2
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/HDCameraUI.cs.meta
  4. 20
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/HDRenderPipelineInspector.cs
  5. 2
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/BaseUI.cs.meta
  6. 2
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/RenderLoopSettings/SerializedFrameSettings.cs.meta
  7. 2
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/RenderLoopSettings/SerializedLightLoopSettings.cs.meta
  8. 2
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/RenderLoopSettings/FrameSettingsUI.cs.meta
  9. 2
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/RenderLoopSettings/LightLoopSettingsUI.cs.meta
  10. 4
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/BaseUI.cs
  11. 28
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/RenderLoopSettings/FrameSettingsUI.cs
  12. 8
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/RenderLoopSettings/LightLoopSettingsUI.cs
  13. 301
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/HDCameraUI.cs
  14. 8
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/RenderLoopSettings.meta
  15. 63
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/HDCameraEditor.Data.cs
  16. 11
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/SerializedUIBase.cs.meta
  17. 238
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/HDCameraEditor.Drawers.cs
  18. 0
      /ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/HDCameraUI.cs.meta
  19. 0
      /ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/BaseUI.cs.meta
  20. 0
      /ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/RenderLoopSettings/SerializedFrameSettings.cs
  21. 0
      /ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/RenderLoopSettings/SerializedFrameSettings.cs.meta
  22. 0
      /ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/RenderLoopSettings/SerializedLightLoopSettings.cs
  23. 0
      /ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/RenderLoopSettings/SerializedLightLoopSettings.cs.meta
  24. 0
      /ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/RenderLoopSettings/FrameSettingsUI.cs.meta
  25. 0
      /ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/RenderLoopSettings/LightLoopSettingsUI.cs.meta
  26. 0
      /ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/BaseUI.cs
  27. 0
      /ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/RenderLoopSettings/FrameSettingsUI.cs
  28. 0
      /ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/RenderLoopSettings/LightLoopSettingsUI.cs

21
ScriptableRenderPipeline/Core/CoreRP/Editor/CoreEditorDrawers.cs


using System;
using System.Collections.Generic;
using System.Security.Principal;
using UnityEditor.AnimatedValues;
using UnityEngine;

public static readonly IDrawer space = Action((state, data, owner) => EditorGUILayout.Space());
public static readonly IDrawer noop = Action((state, data, owner) => { });
public static IDrawer Group(params IDrawer[] drawers)
{
return new GroupDrawerInternal(drawers);
}
public static IDrawer Action(params ActionDrawer[] drawers)
{

params CoreEditorDrawer<T2UIState, T2Data>.IDrawer[] otherDrawers)
{
return new SelectDrawerInternal<T2UIState, T2Data>(stateSelect, dataSelect, otherDrawers);
}
class GroupDrawerInternal : IDrawer
{
IDrawer[] drawers { get; set; }
public GroupDrawerInternal(params IDrawer[] drawers)
{
this.drawers = drawers;
}
void IDrawer.Draw(TUIState s, TData p, Editor owner)
{
for (var i = 0; i < drawers.Length; i++)
drawers[i].Draw(s, p, owner);
}
}
class SelectDrawerInternal<T2UIState, T2Data> : IDrawer

6
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/HDCameraEditor.cs


[CanEditMultipleObjects]
partial class HDCameraEditor : Editor
{
enum ProjectionType { Perspective, Orthographic };
UIState m_UIState = new UIState();
HDCameraUI m_UIState = new HDCameraUI();
RenderTexture m_PreviewTexture;
Camera m_PreviewCamera;

d.Update();
s.Update();
k_PrimarySection.Draw(s, d, this);
HDCameraUI.Inspector.Draw(s, d, this);
d.Apply();
}

2
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/HDCameraUI.cs.meta


fileFormatVersion: 2
guid: c9928fc9bbbbba042be7d81ff05f0add
guid: 8387cedc79c31c64399b2dd76cca7a80
MonoImporter:
externalObjects: {}
serializedVersion: 2

20
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/HDRenderPipelineInspector.cs


namespace UnityEditor.Experimental.Rendering.HDPipeline
{
using CED = CoreEditorDrawer<SerializedFrameSettingsUI, SerializedFrameSettings>;
using CED = CoreEditorDrawer<FrameSettingsUI, SerializedFrameSettings>;
[CustomEditor(typeof(HDRenderPipelineAsset))]
public sealed partial class HDRenderPipelineInspector : HDBaseEditor<HDRenderPipelineAsset>

SerializedFrameSettingsUI.SectionRenderingPasses,
SerializedFrameSettingsUI.SectionRenderingSettings,
FrameSettingsUI.SectionRenderingPasses,
FrameSettingsUI.SectionRenderingSettings,
(s, d, o) => s.serializedLightLoopSettingsUI,
(s, d, o) => s.lightLoopSettingsUI,
SerializedLightLoopSettingsUI.SectionLightLoopSettings),
SerializedFrameSettingsUI.SectionXRSettings
LightLoopSettingsUI.SectionLightLoopSettings),
FrameSettingsUI.SectionXRSettings
};
SerializedProperty m_RenderPipelineResources;

SerializedProperty m_SubsurfaceScatteringSettings;
SerializedFrameSettings serializedFrameSettings = null;
SerializedFrameSettingsUI serializedFrameSettingsUI = new SerializedFrameSettingsUI();
FrameSettingsUI m_FrameSettingsUI = new FrameSettingsUI();
void InitializeProperties()
{

serializedFrameSettings = new SerializedFrameSettings(properties.Find(x => x.serializedFrameSettings));
serializedFrameSettingsUI.Reset(serializedFrameSettings, Repaint);
m_FrameSettingsUI.Reset(serializedFrameSettings, Repaint);
}
static void HackSetDirty(RenderPipelineAsset asset)

CheckStyles();
serializedObject.Update();
serializedFrameSettingsUI.Update();
m_FrameSettingsUI.Update();
EditorGUILayout.PropertyField(m_RenderPipelineResources, s_Styles.renderPipelineResources);
EditorGUILayout.Space();

SettingsUI(m_Target);
k_FrameSettings.Draw(serializedFrameSettingsUI, serializedFrameSettings, this);
k_FrameSettings.Draw(m_FrameSettingsUI, serializedFrameSettings, this);
serializedObject.ApplyModifiedProperties();
}

2
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/BaseUI.cs.meta


fileFormatVersion: 2
guid: 8ff246db187922e4d8a59b2f03e8a595
guid: 16cf8f99963cf854e96c25e5f022bf46
MonoImporter:
externalObjects: {}
serializedVersion: 2

2
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/RenderLoopSettings/SerializedFrameSettings.cs.meta


fileFormatVersion: 2
guid: e99a59ea553fbb94c98d84bdb26d9093
guid: ec542dbaaa88b6d4b9a90540fc168fb5
MonoImporter:
externalObjects: {}
serializedVersion: 2

2
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/RenderLoopSettings/SerializedLightLoopSettings.cs.meta


fileFormatVersion: 2
guid: 757cc63cb14af6d4485632ea47a0f2a1
guid: 8cdd8583a8ae931479505ea608afe6de
MonoImporter:
externalObjects: {}
serializedVersion: 2

2
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/RenderLoopSettings/FrameSettingsUI.cs.meta


fileFormatVersion: 2
guid: e5017bb8546839c4ca4e816932f0245d
guid: 283afa8b170709446893205550b2980f
MonoImporter:
externalObjects: {}
serializedVersion: 2

2
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/RenderLoopSettings/LightLoopSettingsUI.cs.meta


fileFormatVersion: 2
guid: 035f43bd7b3c01b4dbd3d7e33382ec8e
guid: 2217e0c644f08a649b62591c43a0ff35
MonoImporter:
externalObjects: {}
serializedVersion: 2

4
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/BaseUI.cs


namespace UnityEditor.Experimental.Rendering
{
class SerializedUIBase<TType>
class BaseUI<TType>
public SerializedUIBase(int animBoolCount)
public BaseUI(int animBoolCount)
{
m_AnimBools = new AnimBool[animBoolCount];
for (var i = 0; i < m_AnimBools.Length; ++i)

28
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/RenderLoopSettings/FrameSettingsUI.cs


namespace UnityEditor.Experimental.Rendering
{
using _ = CoreEditorUtils;
using CED = CoreEditorDrawer<SerializedFrameSettingsUI, SerializedFrameSettings>;
using CED = CoreEditorDrawer<FrameSettingsUI, SerializedFrameSettings>;
class SerializedFrameSettingsUI : SerializedUIBase<SerializedFrameSettings>
class FrameSettingsUI : BaseUI<SerializedFrameSettings>
{
public static CED.IDrawer SectionRenderingPasses = CED.FoldoutGroup(
"Rendering Passes",

public AnimBool isSectionExpandedUseForwardOnly { get { return m_AnimBools[5]; } }
public AnimBool isSectionExpandedUseDepthPrepass { get { return m_AnimBools[6]; } }
public SerializedLightLoopSettingsUI serializedLightLoopSettingsUI = new SerializedLightLoopSettingsUI();
public LightLoopSettingsUI lightLoopSettingsUI = new LightLoopSettingsUI();
public SerializedFrameSettingsUI()
public FrameSettingsUI()
: base(7)
{
}

serializedLightLoopSettingsUI.Reset(data.lightLoopSettings, repaint);
lightLoopSettingsUI.Reset(data.lightLoopSettings, repaint);
base.Reset(data, repaint);
}

isSectionExpandedUseForwardOnly.target = !data.enableForwardRenderingOnly.boolValue;
isSectionExpandedUseDepthPrepass.target = data.enableDepthPrepassWithDeferredRendering.boolValue;
serializedLightLoopSettingsUI.Update();
lightLoopSettingsUI.Update();
static void Drawer_SectionRenderingPasses(SerializedFrameSettingsUI s, SerializedFrameSettings p, Editor owner)
static void Drawer_SectionRenderingPasses(FrameSettingsUI s, SerializedFrameSettings p, Editor owner)
{
EditorGUILayout.PropertyField(p.enableTransparentPrepass, _.GetContent("Enable Transparent Prepass"));
EditorGUILayout.PropertyField(p.enableTransparentPostpass, _.GetContent("Enable Transparent Postpass"));

EditorGUILayout.PropertyField(p.enablePostprocess, _.GetContent("Enable Postprocess"));
}
static void Drawer_SectionRenderingSettings(SerializedFrameSettingsUI s, SerializedFrameSettings p, Editor owner)
static void Drawer_SectionRenderingSettings(FrameSettingsUI s, SerializedFrameSettings p, Editor owner)
{
EditorGUILayout.PropertyField(p.enableForwardRenderingOnly, _.GetContent("Enable Forward Rendering Only"));
EditorGUILayout.PropertyField(p.enableDepthPrepassWithDeferredRendering, _.GetContent("Enable Depth Prepass With Deferred Rendering"));

EditorGUILayout.PropertyField(p.enableMSAA, _.GetContent("Enable MSAA"));
}
static void Drawer_FieldForwardRenderingOnly(SerializedFrameSettingsUI s, SerializedFrameSettings p, Editor owner)
static void Drawer_FieldForwardRenderingOnly(FrameSettingsUI s, SerializedFrameSettings p, Editor owner)
static void Drawer_FieldUseDepthPrepassWithDefferedRendering(SerializedFrameSettingsUI s, SerializedFrameSettings p, Editor owner)
static void Drawer_FieldUseDepthPrepassWithDefferedRendering(FrameSettingsUI s, SerializedFrameSettings p, Editor owner)
static void Drawer_FieldRenderAlphaTestOnlyInDeferredPrepass(SerializedFrameSettingsUI s, SerializedFrameSettings p, Editor owner)
static void Drawer_FieldRenderAlphaTestOnlyInDeferredPrepass(FrameSettingsUI s, SerializedFrameSettings p, Editor owner)
static void Drawer_SectionOtherRenderingSettings(SerializedFrameSettingsUI s, SerializedFrameSettings p, Editor owner)
static void Drawer_SectionOtherRenderingSettings(FrameSettingsUI s, SerializedFrameSettings p, Editor owner)
{
EditorGUILayout.PropertyField(p.enableAsyncCompute, _.GetContent("Enable Async Compute"));

EditorGUILayout.PropertyField(p.enableMSAA, _.GetContent("Enable MSAA"));
}
static void Drawer_FieldStereoEnabled(SerializedFrameSettingsUI s, SerializedFrameSettings p, Editor owner)
static void Drawer_FieldStereoEnabled(FrameSettingsUI s, SerializedFrameSettings p, Editor owner)
static void Drawer_SectionLightingSettings(SerializedFrameSettingsUI s, SerializedFrameSettings p, Editor owner)
static void Drawer_SectionLightingSettings(FrameSettingsUI s, SerializedFrameSettings p, Editor owner)
{
EditorGUILayout.PropertyField(p.enableSSR, _.GetContent("Enable SSR"));
EditorGUILayout.PropertyField(p.enableSSAO, _.GetContent("Enable SSAO"));

8
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/RenderLoopSettings/LightLoopSettingsUI.cs


namespace UnityEditor.Experimental.Rendering
{
using _ = CoreEditorUtils;
using CED = CoreEditorDrawer<SerializedLightLoopSettingsUI, SerializedLightLoopSettings>;
using CED = CoreEditorDrawer<LightLoopSettingsUI, SerializedLightLoopSettings>;
class SerializedLightLoopSettingsUI : SerializedUIBase<SerializedLightLoopSettings>
class LightLoopSettingsUI : BaseUI<SerializedLightLoopSettings>
{
public static CED.IDrawer SectionLightLoopSettings = CED.FoldoutGroup(
"Light Loop Settings",

public AnimBool isSectionExpandedEnableTileAndCluster { get { return m_AnimBools[1]; } }
public AnimBool isSectionExpandedComputeLightEvaluation { get { return m_AnimBools[2]; } }
public SerializedLightLoopSettingsUI()
public LightLoopSettingsUI()
: base(3)
{
}

base.Update();
}
static void Drawer_SectionLightLoopSettings(SerializedLightLoopSettingsUI s, SerializedLightLoopSettings p, Editor owner)
static void Drawer_SectionLightLoopSettings(LightLoopSettingsUI s, SerializedLightLoopSettings p, Editor owner)
{
EditorGUILayout.PropertyField(p.enableTileAndCluster, _.GetContent("Enable Tile And Cluster"));
GUILayout.BeginVertical();

301
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/HDCameraUI.cs


using System;
using System.Reflection;
using UnityEditor.AnimatedValues;
using UnityEngine;
using UnityEngine.Assertions;
using UnityEngine.Events;
using UnityEngine.Experimental.Rendering.HDPipeline;
using UnityEngine.Rendering;
namespace UnityEditor.Experimental.Rendering
{
using _ = CoreEditorUtils;
using CED = CoreEditorDrawer<HDCameraUI, SerializedHDCamera>;
class HDCameraUI : BaseUI<SerializedHDCamera>
{
static HDCameraUI()
{
Inspector = new []
{
SectionPrimarySettings,
SectionCaptureSettings,
SectionOutputSettings,
SectionXRSettings,
SectionRenderLoopSettings
};
}
public static readonly CED.IDrawer[] Inspector = null;
public static readonly CED.IDrawer SectionPrimarySettings = CED.Group(
CED.Action(Drawer_FieldBackgroundColor),
CED.Action(Drawer_FieldCullingMask),
CED.Action(Drawer_FieldVolumeLayerMask),
CED.space,
CED.Action(Drawer_Projection),
CED.Action(Drawer_FieldClippingPlanes),
CED.space,
CED.Action(Drawer_CameraWarnings),
CED.Action(Drawer_FieldRenderingPath),
CED.space
);
public static readonly CED.IDrawer SectionCaptureSettings = CED.FoldoutGroup(
"Capture Settings",
(s, p, o) => s.isSectionExpandedCaptureSettings,
true,
CED.Action(Drawer_FieldOcclusionCulling),
CED.Action(Drawer_FieldNormalizedViewPort));
public static readonly CED.IDrawer SectionOutputSettings = CED.FoldoutGroup(
"Output Settings",
(s, p, o) => s.isSectionExpandedOutputSettings,
true,
#if ENABLE_MULTIPLE_DISPLAYS
CED.Action(Drawer_SectionMultiDisplay),
#endif
CED.Action(Drawer_FieldDepth),
CED.Action(Drawer_FieldRenderTarget));
public static readonly CED.IDrawer SectionXRSettings = CED.FadeGroup(
(s, d, o, i) => s.isSectionAvailableXRSettings,
false,
CED.FoldoutGroup(
"XR Settings",
(s, p, o) => s.isSectionExpandedXRSettings,
true,
CED.Action(Drawer_FieldVR),
CED.Action(Drawer_FieldTargetEye)));
public static readonly CED.IDrawer SectionRenderLoopSettings = CED.FadeGroup(
(s, d, o, i) => s.isSectionAvailableRenderLoopSettings,
false,
CED.Select(
(s, d, o) => s.frameSettingsUI,
(s, d, o) => d.frameSettings,
FrameSettingsUI.SectionRenderingPasses,
FrameSettingsUI.SectionRenderingSettings,
FrameSettingsUI.SectionLightingSettings),
CED.Select(
(s, d, o) => s.frameSettingsUI.lightLoopSettingsUI,
(s, d, o) => d.frameSettings.lightLoopSettings,
LightLoopSettingsUI.SectionLightLoopSettings));
enum ProjectionType { Perspective, Orthographic };
SerializedHDCamera m_SerializedHdCamera;
public AnimBool isSectionExpandedOrthoOptions { get { return m_AnimBools[0]; } }
public AnimBool isSectionExpandedCaptureSettings { get { return m_AnimBools[1]; } }
public AnimBool isSectionExpandedOutputSettings { get { return m_AnimBools[2]; } }
public AnimBool isSectionAvailableRenderLoopSettings { get { return m_AnimBools[3]; } }
public AnimBool isSectionExpandedXRSettings { get { return m_AnimBools[4]; } }
public AnimBool isSectionAvailableXRSettings { get { return m_AnimBools[5]; } }
public bool canOverrideRenderLoopSettings { get; set; }
public FrameSettingsUI frameSettingsUI = new FrameSettingsUI();
public HDCameraUI()
: base(6)
{
canOverrideRenderLoopSettings = false;
}
public override void Reset(SerializedHDCamera data, UnityAction repaint)
{
m_SerializedHdCamera = data;
frameSettingsUI.Reset(data.frameSettings, repaint);
for (var i = 0; i < m_AnimBools.Length; ++i)
{
m_AnimBools[i].valueChanged.RemoveAllListeners();
m_AnimBools[i].valueChanged.AddListener(repaint);
}
Update();
}
public override void Update()
{
base.Update();
var renderingPath = (HDAdditionalCameraData.RenderingPath)m_SerializedHdCamera.renderingPath.intValue;
canOverrideRenderLoopSettings = renderingPath == HDAdditionalCameraData.RenderingPath.Custom;
isSectionExpandedOrthoOptions.target = !m_SerializedHdCamera.orthographic.hasMultipleDifferentValues && m_SerializedHdCamera.orthographic.boolValue;
isSectionAvailableXRSettings.target = PlayerSettings.virtualRealitySupported;
// SRP settings are available only if the rendering path is not the Default one (configured by the SRP asset)
isSectionAvailableRenderLoopSettings.target = canOverrideRenderLoopSettings;
frameSettingsUI.Update();
}
static void Drawer_FieldBackgroundColor(HDCameraUI s, SerializedHDCamera p, Editor owner)
{
EditorGUILayout.PropertyField(p.backgroundColor, _.GetContent("Background Color|The Camera clears the screen to this color before rendering."));
}
static void Drawer_FieldVolumeLayerMask(HDCameraUI s, SerializedHDCamera p, Editor owner)
{
EditorGUILayout.PropertyField(p.volumeLayerMask, _.GetContent("Volume Layer Mask"));
}
static void Drawer_FieldCullingMask(HDCameraUI s, SerializedHDCamera p, Editor owner)
{
EditorGUILayout.PropertyField(p.cullingMask, _.GetContent("Culling Mask"));
}
static void Drawer_Projection(HDCameraUI s, SerializedHDCamera p, Editor owner)
{
ProjectionType projectionType = p.orthographic.boolValue ? ProjectionType.Orthographic : ProjectionType.Perspective;
EditorGUI.BeginChangeCheck();
EditorGUI.showMixedValue = p.orthographic.hasMultipleDifferentValues;
projectionType = (ProjectionType)EditorGUILayout.EnumPopup(_.GetContent("Projection|How the Camera renders perspective.\n\nChoose Perspective to render objects with perspective.\n\nChoose Orthographic to render objects uniformly, with no sense of perspective."), projectionType);
EditorGUI.showMixedValue = false;
if (EditorGUI.EndChangeCheck())
p.orthographic.boolValue = (projectionType == ProjectionType.Orthographic);
if (!p.orthographic.hasMultipleDifferentValues)
{
if (projectionType == ProjectionType.Orthographic)
EditorGUILayout.PropertyField(p.orthographicSize, _.GetContent("Size"));
else
EditorGUILayout.Slider(p.fieldOfView, 1f, 179f, _.GetContent("Field of View|The width of the Camera’s view angle, measured in degrees along the local Y axis."));
}
}
static void Drawer_FieldClippingPlanes(HDCameraUI s, SerializedHDCamera p, Editor owner)
{
GUILayout.BeginHorizontal();
EditorGUILayout.PrefixLabel(_.GetContent("Clipping Planes"));
GUILayout.BeginVertical();
var labelWidth = EditorGUIUtility.labelWidth;
EditorGUIUtility.labelWidth = 45;
EditorGUILayout.PropertyField(p.nearClippingPlane, _.GetContent("Near|The closest point relative to the camera that drawing will occur."));
EditorGUILayout.PropertyField(p.farClippingPlane, _.GetContent("Far|The furthest point relative to the camera that drawing will occur.\n"));
GUILayout.EndVertical();
GUILayout.EndHorizontal();
EditorGUIUtility.labelWidth = labelWidth;
}
static void Drawer_FieldNormalizedViewPort(HDCameraUI s, SerializedHDCamera p, Editor owner)
{
EditorGUILayout.PropertyField(p.normalizedViewPortRect, _.GetContent("Viewport Rect|Four values that indicate where on the screen this camera view will be drawn. Measured in Viewport Coordinates (values 0–1)."));
}
static void Drawer_FieldDepth(HDCameraUI s, SerializedHDCamera p, Editor owner)
{
EditorGUILayout.PropertyField(p.depth, _.GetContent("Depth"));
}
static void Drawer_FieldRenderingPath(HDCameraUI s, SerializedHDCamera p, Editor owner)
{
EditorGUILayout.PropertyField(p.renderingPath, _.GetContent("Rendering Path"));
}
static void Drawer_FieldRenderTarget(HDCameraUI s, SerializedHDCamera p, Editor owner)
{
EditorGUILayout.PropertyField(p.targetTexture);
// show warning if we have deferred but manual MSAA set
// only do this if the m_TargetTexture has the same values across all target cameras
if (!p.targetTexture.hasMultipleDifferentValues)
{
var targetTexture = p.targetTexture.objectReferenceValue as RenderTexture;
if (targetTexture
&& targetTexture.antiAliasing > 1
&& !p.frameSettings.enableForwardRenderingOnly.boolValue)
{
EditorGUILayout.HelpBox("Manual MSAA target set with deferred rendering. This will lead to undefined behavior.", MessageType.Warning, true);
}
}
}
static void Drawer_FieldOcclusionCulling(HDCameraUI s, SerializedHDCamera p, Editor owner)
{
EditorGUILayout.PropertyField(p.occlusionCulling, _.GetContent("Occlusion Culling"));
}
static void Drawer_CameraWarnings(HDCameraUI s, SerializedHDCamera p, Editor owner)
{
foreach (Camera camera in p.serializedObject.targetObjects)
{
var warnings = GetCameraBufferWarnings(camera);
if (warnings.Length > 0)
EditorGUILayout.HelpBox(string.Join("\n\n", warnings), MessageType.Warning, true);
}
}
static void Drawer_FieldVR(HDCameraUI s, SerializedHDCamera p, Editor owner)
{
if (s.canOverrideRenderLoopSettings)
EditorGUILayout.PropertyField(p.frameSettings.enableStereo, _.GetContent("Enable Stereo"));
else
{
var hdrp = GraphicsSettings.renderPipelineAsset as HDRenderPipelineAsset;
Assert.IsNotNull(hdrp, "This Editor is valid only for HDRP");
var enableStereo = hdrp.GetFrameSettings().enableStereo;
GUI.enabled = false;
EditorGUILayout.Toggle(_.GetContent("Enable Stereo (Set by HDRP)"), enableStereo);
GUI.enabled = true;
}
EditorGUILayout.PropertyField(p.stereoSeparation, _.GetContent("Stereo Separation"));
EditorGUILayout.PropertyField(p.stereoConvergence, _.GetContent("Stereo Convergence"));
}
#if ENABLE_MULTIPLE_DISPLAYS
static void Drawer_SectionMultiDisplay(HDCameraUI s, SerializedHDCamera p, Editor owner)
{
if (ModuleManager_ShouldShowMultiDisplayOption())
{
var prevDisplay = p.targetDisplay.intValue;
EditorGUILayout.IntPopup(p.targetDisplay, DisplayUtility_GetDisplayNames(), DisplayUtility_GetDisplayIndices(), _.GetContent("Target Display"));
if (prevDisplay != p.targetDisplay.intValue)
UnityEditorInternal.InternalEditorUtility.RepaintAllViews();
}
}
#endif
static readonly int[] k_TargetEyeValues = { (int)StereoTargetEyeMask.Both, (int)StereoTargetEyeMask.Left, (int)StereoTargetEyeMask.Right, (int)StereoTargetEyeMask.None };
static readonly GUIContent[] k_TargetEyes =
{
new GUIContent("Both"),
new GUIContent("Left"),
new GUIContent("Right"),
new GUIContent("None (Main Display)"),
};
static void Drawer_FieldTargetEye(HDCameraUI s, SerializedHDCamera p, Editor owner)
{
EditorGUILayout.IntPopup(p.targetEye, k_TargetEyes, k_TargetEyeValues, _.GetContent("Target Eye"));
}
static MethodInfo k_DisplayUtility_GetDisplayIndices = Type.GetType("UnityEditor.DisplayUtility,UnityEditor")
.GetMethod("GetDisplayIndices");
static int[] DisplayUtility_GetDisplayIndices()
{
return (int[])k_DisplayUtility_GetDisplayIndices.Invoke(null, null);
}
static MethodInfo k_DisplayUtility_GetDisplayNames = Type.GetType("UnityEditor.DisplayUtility,UnityEditor")
.GetMethod("GetDisplayNames");
static GUIContent[] DisplayUtility_GetDisplayNames()
{
return (GUIContent[])k_DisplayUtility_GetDisplayNames.Invoke(null, null);
}
static MethodInfo k_ModuleManager_ShouldShowMultiDisplayOption = Type.GetType("UnityEditor.Modules.ModuleManager,UnityEditor")
.GetMethod("ShouldShowMultiDisplayOption", BindingFlags.Static | BindingFlags.NonPublic);
static bool ModuleManager_ShouldShowMultiDisplayOption()
{
return (bool)k_ModuleManager_ShouldShowMultiDisplayOption.Invoke(null, null);
}
static readonly MethodInfo k_Camera_GetCameraBufferWarnings = typeof(Camera).GetMethod("GetCameraBufferWarnings", BindingFlags.Instance | BindingFlags.NonPublic);
static string[] GetCameraBufferWarnings(Camera camera)
{
return (string[])k_Camera_GetCameraBufferWarnings.Invoke(camera, null);
}
}
}

8
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/RenderLoopSettings.meta


fileFormatVersion: 2
guid: beec4e0c83397f34086a0bf8d0063062
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

63
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/HDCameraEditor.Data.cs


using UnityEditor.AnimatedValues;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Experimental.Rendering.HDPipeline;
namespace UnityEditor.Experimental.Rendering
{
partial class HDCameraEditor
{
public class UIState
{
SerializedHDCamera m_SerializedHdCamera;
AnimBool[] m_AnimBools = new AnimBool[6];
public AnimBool isSectionExpandedOrthoOptions { get { return m_AnimBools[0]; } }
public AnimBool isSectionExpandedCaptureSettings { get { return m_AnimBools[1]; } }
public AnimBool isSectionExpandedOutputSettings { get { return m_AnimBools[2]; } }
public AnimBool isSectionAvailableRenderLoopSettings { get { return m_AnimBools[3]; } }
public AnimBool isSectionExpandedXRSettings { get { return m_AnimBools[4]; } }
public AnimBool isSectionAvailableXRSettings { get { return m_AnimBools[5]; } }
public bool canOverrideRenderLoopSettings { get; set; }
public SerializedFrameSettingsUI serializedFrameSettingsUI = new SerializedFrameSettingsUI();
public UIState()
{
for (var i = 0 ; i < m_AnimBools.Length; ++i)
m_AnimBools[i] = new AnimBool();
canOverrideRenderLoopSettings = false;
}
public void Reset(SerializedHDCamera serializedHdCamera, UnityAction repaint)
{
m_SerializedHdCamera = serializedHdCamera;
serializedFrameSettingsUI.Reset(serializedHdCamera.frameSettings, repaint);
for (var i = 0; i < m_AnimBools.Length; ++i)
{
m_AnimBools[i].valueChanged.RemoveAllListeners();
m_AnimBools[i].valueChanged.AddListener(repaint);
}
Update();
}
public void Update()
{
var renderingPath = (HDAdditionalCameraData.RenderingPath)m_SerializedHdCamera.renderingPath.intValue;
canOverrideRenderLoopSettings = renderingPath == HDAdditionalCameraData.RenderingPath.Custom;
isSectionExpandedOrthoOptions.target = !m_SerializedHdCamera.orthographic.hasMultipleDifferentValues && m_SerializedHdCamera.orthographic.boolValue;
isSectionAvailableXRSettings.target = PlayerSettings.virtualRealitySupported;
// SRP settings are available only if the rendering path is not the Default one (configured by the SRP asset)
isSectionAvailableRenderLoopSettings.target = canOverrideRenderLoopSettings;
serializedFrameSettingsUI.Update();
}
}
}
}

11
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/SerializedUIBase.cs.meta


fileFormatVersion: 2
guid: 552d470a524dbaa44bd6833071913719
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

238
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/HDCameraEditor.Drawers.cs


using System;
using System.Linq;
using System.Reflection;
using UnityEngine;
using UnityEngine.Assertions;
using UnityEngine.Experimental.Rendering.HDPipeline;
using UnityEngine.Rendering;
namespace UnityEditor.Experimental.Rendering
{
using _ = CoreEditorUtils;
using CED = CoreEditorDrawer<HDCameraEditor.UIState, SerializedHDCamera>;
partial class HDCameraEditor
{
static readonly CED.IDrawer[] k_PrimarySection =
{
// Primary settings
CED.Action(Drawer_FieldBackgroundColor),
CED.Action(Drawer_FieldCullingMask),
CED.Action(Drawer_FieldVolumeLayerMask),
CED.space,
CED.Action(Drawer_Projection),
CED.Action(Drawer_FieldClippingPlanes),
CED.space,
CED.Action(Drawer_CameraWarnings),
CED.Action(Drawer_FieldRenderingPath),
CED.space,
// Advanced settings
CED.FoldoutGroup(
"Capture Settings",
(s, p, o) => s.isSectionExpandedCaptureSettings,
true,
CED.Action(Drawer_FieldOcclusionCulling),
CED.Action(Drawer_FieldNormalizedViewPort)),
CED.FoldoutGroup(
"Output Settings",
(s, p, o) => s.isSectionExpandedOutputSettings,
true,
#if ENABLE_MULTIPLE_DISPLAYS
CED.Action(Drawer_SectionMultiDisplay),
#endif
CED.Action(Drawer_FieldDepth),
CED.Action(Drawer_FieldRenderTarget)),
CED.FadeGroup(
(s, d, o, i) => s.isSectionAvailableXRSettings,
false,
CED.FoldoutGroup(
"XR Settings",
(s, p, o) => s.isSectionExpandedXRSettings,
true,
CED.Action(Drawer_FieldVR),
CED.Action(Drawer_FieldTargetEye))),
// Render Loop Settings
CED.FadeGroup(
(s, d, o, i) => s.isSectionAvailableRenderLoopSettings,
false,
CED.Select(
(s, d, o) => s.serializedFrameSettingsUI,
(s, d, o) => d.frameSettings,
SerializedFrameSettingsUI.SectionRenderingPasses,
SerializedFrameSettingsUI.SectionRenderingSettings,
SerializedFrameSettingsUI.SectionLightingSettings),
CED.Select(
(s, d, o) => s.serializedFrameSettingsUI.serializedLightLoopSettingsUI,
(s, d, o) => d.frameSettings.lightLoopSettings,
SerializedLightLoopSettingsUI.SectionLightLoopSettings))
};
static void Drawer_FieldBackgroundColor(UIState s, SerializedHDCamera p, Editor owner)
{
EditorGUILayout.PropertyField(p.backgroundColor, _.GetContent("Background Color|The Camera clears the screen to this color before rendering."));
}
static void Drawer_FieldVolumeLayerMask(UIState s, SerializedHDCamera p, Editor owner)
{
EditorGUILayout.PropertyField(p.volumeLayerMask, _.GetContent("Volume Layer Mask"));
}
static void Drawer_FieldCullingMask(UIState s, SerializedHDCamera p, Editor owner)
{
EditorGUILayout.PropertyField(p.cullingMask, _.GetContent("Culling Mask"));
}
static void Drawer_Projection(UIState s, SerializedHDCamera p, Editor owner)
{
ProjectionType projectionType = p.orthographic.boolValue ? ProjectionType.Orthographic : ProjectionType.Perspective;
EditorGUI.BeginChangeCheck();
EditorGUI.showMixedValue = p.orthographic.hasMultipleDifferentValues;
projectionType = (ProjectionType)EditorGUILayout.EnumPopup(_.GetContent("Projection|How the Camera renders perspective.\n\nChoose Perspective to render objects with perspective.\n\nChoose Orthographic to render objects uniformly, with no sense of perspective."), projectionType);
EditorGUI.showMixedValue = false;
if (EditorGUI.EndChangeCheck())
p.orthographic.boolValue = (projectionType == ProjectionType.Orthographic);
if (!p.orthographic.hasMultipleDifferentValues)
{
if (projectionType == ProjectionType.Orthographic)
EditorGUILayout.PropertyField(p.orthographicSize, _.GetContent("Size"));
else
EditorGUILayout.Slider(p.fieldOfView, 1f, 179f, _.GetContent("Field of View|The width of the Camera’s view angle, measured in degrees along the local Y axis."));
}
}
static void Drawer_FieldClippingPlanes(UIState s, SerializedHDCamera p, Editor owner)
{
GUILayout.BeginHorizontal();
EditorGUILayout.PrefixLabel(_.GetContent("Clipping Planes"));
GUILayout.BeginVertical();
var labelWidth = EditorGUIUtility.labelWidth;
EditorGUIUtility.labelWidth = 45;
EditorGUILayout.PropertyField(p.nearClippingPlane, _.GetContent("Near|The closest point relative to the camera that drawing will occur."));
EditorGUILayout.PropertyField(p.farClippingPlane, _.GetContent("Far|The furthest point relative to the camera that drawing will occur.\n"));
GUILayout.EndVertical();
GUILayout.EndHorizontal();
EditorGUIUtility.labelWidth = labelWidth;
}
static void Drawer_FieldNormalizedViewPort(UIState s, SerializedHDCamera p, Editor owner)
{
EditorGUILayout.PropertyField(p.normalizedViewPortRect, _.GetContent("Viewport Rect|Four values that indicate where on the screen this camera view will be drawn. Measured in Viewport Coordinates (values 0–1)."));
}
static void Drawer_FieldDepth(UIState s, SerializedHDCamera p, Editor owner)
{
EditorGUILayout.PropertyField(p.depth, _.GetContent("Depth"));
}
static void Drawer_FieldRenderingPath(UIState s, SerializedHDCamera p, Editor owner)
{
EditorGUILayout.PropertyField(p.renderingPath, _.GetContent("Rendering Path"));
}
static void Drawer_FieldRenderTarget(UIState s, SerializedHDCamera p, Editor owner)
{
EditorGUILayout.PropertyField(p.targetTexture);
// show warning if we have deferred but manual MSAA set
// only do this if the m_TargetTexture has the same values across all target cameras
if (!p.targetTexture.hasMultipleDifferentValues)
{
var targetTexture = p.targetTexture.objectReferenceValue as RenderTexture;
if (targetTexture
&& targetTexture.antiAliasing > 1
&& !p.frameSettings.enableForwardRenderingOnly.boolValue)
{
EditorGUILayout.HelpBox("Manual MSAA target set with deferred rendering. This will lead to undefined behavior.", MessageType.Warning, true);
}
}
}
static void Drawer_FieldOcclusionCulling(UIState s, SerializedHDCamera p, Editor owner)
{
EditorGUILayout.PropertyField(p.occlusionCulling, _.GetContent("Occlusion Culling"));
}
static void Drawer_CameraWarnings(UIState s, SerializedHDCamera p, Editor owner)
{
foreach (Camera camera in p.serializedObject.targetObjects)
{
var warnings = GetCameraBufferWarnings(camera);
if (warnings.Length > 0)
EditorGUILayout.HelpBox(string.Join("\n\n", warnings), MessageType.Warning, true);
}
}
static void Drawer_FieldVR(UIState s, SerializedHDCamera p, Editor owner)
{
if (s.canOverrideRenderLoopSettings)
EditorGUILayout.PropertyField(p.frameSettings.enableStereo, _.GetContent("Enable Stereo"));
else
{
var hdrp = GraphicsSettings.renderPipelineAsset as HDRenderPipelineAsset;
Assert.IsNotNull(hdrp, "This Editor is valid only for HDRP");
var enableStereo = hdrp.GetFrameSettings().enableStereo;
GUI.enabled = false;
EditorGUILayout.Toggle(_.GetContent("Enable Stereo (Set by HDRP)"), enableStereo);
GUI.enabled = true;
}
EditorGUILayout.PropertyField(p.stereoSeparation, _.GetContent("Stereo Separation"));
EditorGUILayout.PropertyField(p.stereoConvergence, _.GetContent("Stereo Convergence"));
}
#if ENABLE_MULTIPLE_DISPLAYS
static void Drawer_SectionMultiDisplay(UIState s, SerializedHDCamera p, Editor owner)
{
if (ModuleManager_ShouldShowMultiDisplayOption())
{
var prevDisplay = p.targetDisplay.intValue;
EditorGUILayout.IntPopup(p.targetDisplay, DisplayUtility_GetDisplayNames(), DisplayUtility_GetDisplayIndices(), _.GetContent("Target Display"));
if (prevDisplay != p.targetDisplay.intValue)
UnityEditorInternal.InternalEditorUtility.RepaintAllViews();
}
}
#endif
static readonly int[] k_TargetEyeValues = { (int)StereoTargetEyeMask.Both, (int)StereoTargetEyeMask.Left, (int)StereoTargetEyeMask.Right, (int)StereoTargetEyeMask.None };
static readonly GUIContent[] k_TargetEyes =
{
new GUIContent("Both"),
new GUIContent("Left"),
new GUIContent("Right"),
new GUIContent("None (Main Display)"),
};
static void Drawer_FieldTargetEye(UIState s, SerializedHDCamera p, Editor owner)
{
EditorGUILayout.IntPopup(p.targetEye, k_TargetEyes, k_TargetEyeValues, _.GetContent("Target Eye"));
}
static MethodInfo k_DisplayUtility_GetDisplayIndices = Type.GetType("UnityEditor.DisplayUtility,UnityEditor")
.GetMethod("GetDisplayIndices");
static int[] DisplayUtility_GetDisplayIndices()
{
return (int[])k_DisplayUtility_GetDisplayIndices.Invoke(null, null);
}
static MethodInfo k_DisplayUtility_GetDisplayNames = Type.GetType("UnityEditor.DisplayUtility,UnityEditor")
.GetMethod("GetDisplayNames");
static GUIContent[] DisplayUtility_GetDisplayNames()
{
return (GUIContent[])k_DisplayUtility_GetDisplayNames.Invoke(null, null);
}
static MethodInfo k_ModuleManager_ShouldShowMultiDisplayOption = Type.GetType("UnityEditor.Modules.ModuleManager,UnityEditor")
.GetMethod("ShouldShowMultiDisplayOption", BindingFlags.Static | BindingFlags.NonPublic);
static bool ModuleManager_ShouldShowMultiDisplayOption()
{
return (bool)k_ModuleManager_ShouldShowMultiDisplayOption.Invoke(null, null);
}
static readonly MethodInfo k_Camera_GetCameraBufferWarnings = typeof(Camera).GetMethod("GetCameraBufferWarnings", BindingFlags.Instance | BindingFlags.NonPublic);
static string[] GetCameraBufferWarnings(Camera camera)
{
return (string[])k_Camera_GetCameraBufferWarnings.Invoke(camera, null);
}
}
}

/ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/HDCameraEditor.Data.cs.meta → /ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/HDCameraUI.cs.meta

/ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/HDCameraEditor.Drawers.cs.meta → /ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/BaseUI.cs.meta

/ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/SerializedFrameSettings.cs → /ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/RenderLoopSettings/SerializedFrameSettings.cs

/ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/SerializedFrameSettings.cs.meta → /ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/RenderLoopSettings/SerializedFrameSettings.cs.meta

/ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/SerializedLightLoopSettings.cs → /ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/RenderLoopSettings/SerializedLightLoopSettings.cs

/ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/SerializedLightLoopSettings.cs.meta → /ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/RenderLoopSettings/SerializedLightLoopSettings.cs.meta

/ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/SerializedFrameSettingsUI.cs.meta → /ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/RenderLoopSettings/FrameSettingsUI.cs.meta

/ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/SerializedLightLoopSettingsUI.cs.meta → /ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/RenderLoopSettings/LightLoopSettingsUI.cs.meta

/ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/SerializedUIBase.cs → /ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/BaseUI.cs

/ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/SerializedFrameSettingsUI.cs → /ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/RenderLoopSettings/FrameSettingsUI.cs

/ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/SerializedLightLoopSettingsUI.cs → /ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/RenderLoopSettings/LightLoopSettingsUI.cs

正在加载...
取消
保存