浏览代码

Updated drawers

/feature-ReflectionProbeFit
Frédéric Vauchelles 7 年前
当前提交
5e6d2b66
共有 4 个文件被更改,包括 90 次插入35 次删除
  1. 44
      ScriptableRenderPipeline/Core/Editor/CoreEditorDrawers.cs
  2. 24
      ScriptableRenderPipeline/HDRenderPipeline/Editor/Lighting/HDReflectionProbeEditor.Data.cs
  3. 49
      ScriptableRenderPipeline/HDRenderPipeline/Editor/Lighting/HDReflectionProbeEditor.Drawers.cs
  4. 8
      ScriptableRenderPipeline/HDRenderPipeline/Editor/Lighting/HDReflectionProbeEditor.cs

44
ScriptableRenderPipeline/Core/Editor/CoreEditorDrawers.cs


namespace UnityEditor.Experimental.Rendering
using System.Collections.Generic;
namespace UnityEditor.Experimental.Rendering
{
public static class CoreEditorDrawer<TUIState, TData>
{

public delegate float FloatGetter(TUIState s, TData p, Editor owner, int i);
public delegate SerializedProperty SerializedPropertyGetter(TUIState s, TData p, Editor o);
public static readonly IDrawer space = Action((state, data, owner) => EditorGUILayout.Space());
public static readonly IDrawer noop = Action((state, data, owner) => { });
public static IDrawer Action(params ActionDrawer[] drawers)
{

public static IDrawer FadeGroup(FloatGetter fadeGetter, params IDrawer[] groupDrawers)
public static IDrawer FadeGroup(FloatGetter fadeGetter, bool indent, params IDrawer[] groupDrawers)
return new FadeGroupsDrawerInternal(fadeGetter, groupDrawers);
return new FadeGroupsDrawerInternal(fadeGetter, indent, groupDrawers);
public static IDrawer FoldoutGroup(string title, SerializedPropertyGetter root, params IDrawer[] bodies)
public static IDrawer FoldoutGroup(string title, SerializedPropertyGetter root, bool indent, params IDrawer[] bodies)
return new FoldoutDrawerInternal(title, root, bodies);
return new FoldoutDrawerInternal(title, root, indent, bodies);
class ActionDrawerInternal : IDrawer
{

{
IDrawer[] groupDrawers;
FloatGetter getter;
bool indent;
public FadeGroupsDrawerInternal(FloatGetter getter, params IDrawer[] groupDrawers)
public FadeGroupsDrawerInternal(FloatGetter getter, bool indent, params IDrawer[] groupDrawers)
this.indent = indent;
}
void IDrawer.Draw(TUIState s, TData p, Editor owner)

if (EditorGUILayout.BeginFadeGroup(getter(s, p, owner, i)))
{
++EditorGUI.indentLevel;
if (indent)
++EditorGUI.indentLevel;
--EditorGUI.indentLevel;
if (indent)
--EditorGUI.indentLevel;
}
EditorGUILayout.EndFadeGroup();
}

IDrawer[] bodies;
SerializedPropertyGetter root;
string title;
bool indent;
public FoldoutDrawerInternal(string title, SerializedPropertyGetter root, params IDrawer[] bodies)
public FoldoutDrawerInternal(string title, SerializedPropertyGetter root, bool indent, params IDrawer[] bodies)
this.indent = indent;
}
public void Draw(TUIState s, TData p, Editor owner)

r.isExpanded = CoreEditorUtils.DrawHeaderFoldout(title, r.isExpanded);
if (r.isExpanded)
{
++EditorGUI.indentLevel;
if (indent)
++EditorGUI.indentLevel;
--EditorGUI.indentLevel;
if (indent)
--EditorGUI.indentLevel;
}
}
public static class CoreEditorDrawersExtensions
{
public static void Draw<TUIState, TData>(this IEnumerable<CoreEditorDrawer<TUIState, TData>.IDrawer> drawers, TUIState s, TData p, Editor o)
{
foreach (var drawer in drawers)
drawer.Draw(s, p, o);
}
}
}

24
ScriptableRenderPipeline/HDRenderPipeline/Editor/Lighting/HDReflectionProbeEditor.Data.cs


internal SerializedProperty boxOffset;
internal SerializedProperty influenceShape;
internal SerializedProperty influenceSphereRadius;
internal SerializedProperty influenceSphereRadius;
internal SerializedProperty boxReprojectionVolumeSize;
internal SerializedProperty boxReprojectionVolumeCenter;
internal SerializedProperty sphereReprojectionVolumeRadius;
public SerializedReflectionProbe(SerializedObject so, SerializedObject addso)
{

influenceShape = addso.Find((HDAdditionalReflectionData d) => d.m_InfluenceShape);
influenceSphereRadius = addso.Find((HDAdditionalReflectionData d) => d.m_InfluenceSphereRadius);
useSeparateProjectionVolume = addso.Find((HDAdditionalReflectionData d) => d.m_UseSeparateProjectionVolume);
boxReprojectionVolumeSize = addso.Find((HDAdditionalReflectionData d) => d.m_BoxReprojectionVolumeSize);
boxReprojectionVolumeCenter = addso.Find((HDAdditionalReflectionData d) => d.m_BoxReprojectionVolumeCenter);
sphereReprojectionVolumeRadius = addso.Find((HDAdditionalReflectionData d) => d.m_SphereReprojectionVolumeRadius);
}
}

Editor owner { get; set; }
Operation operations { get; set; }
public AnimBool useSeparateProjectionVolumeDisplay { get; private set; }
public bool HasOperation(Operation op) { return (operations & op) == op; }
public void ClearOperation(Operation op) { operations &= ~op; }
public void AddOperation(Operation op) { operations |= op; }

m_ModeSettingsDisplays[i] = new AnimBool();
for (var i = 0; i < m_InfluenceShapeDisplays.Length; i++)
m_InfluenceShapeDisplays[i] = new AnimBool();
useSeparateProjectionVolumeDisplay = new AnimBool();
internal void Reset(Editor owner, UnityAction repaint, int modeValue, int shapeValue)
internal void Reset(
Editor owner,
UnityAction repaint,
SerializedReflectionProbe p)
{
this.owner = owner;
operations = 0;

m_ModeSettingsDisplays[i].valueChanged.RemoveAllListeners();
m_ModeSettingsDisplays[i].valueChanged.AddListener(repaint);
m_ModeSettingsDisplays[i].value = modeValue == i;
m_ModeSettingsDisplays[i].value = p.mode.intValue == i;
}
for (var i = 0; i < m_InfluenceShapeDisplays.Length; i++)

m_InfluenceShapeDisplays[i].value = shapeValue == i;
m_InfluenceShapeDisplays[i].value = p.influenceShape.intValue == i;
useSeparateProjectionVolumeDisplay.valueChanged.RemoveAllListeners();
useSeparateProjectionVolumeDisplay.valueChanged.AddListener(repaint);
useSeparateProjectionVolumeDisplay.value = p.useSeparateProjectionVolume.boolValue;
}
public float GetModeFaded(ReflectionProbeMode mode)

49
ScriptableRenderPipeline/HDRenderPipeline/Editor/Lighting/HDReflectionProbeEditor.Drawers.cs


partial class HDReflectionProbeEditor
{
static readonly CED.IDrawer k_Drawer_Space = CED.Action(Drawer_Space);
static readonly CED.IDrawer k_Drawer_NOOP = CED.Action(Drawer_NOOP);
static void Drawer_NOOP(UIState s, SerializedReflectionProbe p, Editor owner) { }
static void Drawer_Space(UIState s, SerializedReflectionProbe p, Editor owner) { EditorGUILayout.Space(); }

(s, p, o) => p.blendDistance,
true,
false,
CED.Action(Drawer_InfluenceBoxSettings), // Box
CED.Action(Drawer_InfluenceSphereSettings) // Sphere
),

static readonly CED.IDrawer k_SeparateProjectionVolumeSection = CED.FadeGroup(
(s, p, o, i) => s.useSeparateProjectionVolumeDisplay.faded,
false,
CED.FoldoutGroup(
"Reprojection volume settings",
(s, p, o) => p.useSeparateProjectionVolume,
true,
CED.FadeGroup(
(s, p, o, i) => s.GetShapeFaded((ReflectionInfluenceShape)i),
false,
CED.Action(Drawer_ProjectionBoxSettings), // Box
CED.Action(Drawer_ProjectionSphereSettings) // Sphere
)
)
);
k_Drawer_NOOP, // Baked
true,
CED.noop, // Baked
k_Drawer_Space,
CED.space,
k_Drawer_Space,
CED.space,
k_Drawer_Space
CED.space
void Draw(CED.IDrawer[] drawers, UIState s, SerializedReflectionProbe p, Editor owner)
{
for (var i = 0; i < drawers.Length; i++)
drawers[i].Draw(s, p, owner);
}
#endregion
static void Drawer_InfluenceBoxSettings(UIState s, SerializedReflectionProbe p, Editor owner)

}
}
static void Drawer_ProjectionBoxSettings(UIState s, SerializedReflectionProbe p, Editor owner)
{
EditorGUILayout.PropertyField(p.boxReprojectionVolumeSize);
EditorGUILayout.PropertyField(p.boxReprojectionVolumeCenter);
}
static void Drawer_ProjectionSphereSettings(UIState s, SerializedReflectionProbe p, Editor owner)
{
EditorGUILayout.PropertyField(p.sphereReprojectionVolumeRadius);
}
static void Drawer_InfluenceSphereSettings(UIState s, SerializedReflectionProbe p, Editor owner)
{
EditorGUILayout.PropertyField(p.influenceSphereRadius, CoreEditorUtils.GetContent("Radius"));

{
EditorGUILayout.PropertyField(p.useSeparateProjectionVolume);
s.useSeparateProjectionVolumeDisplay.target = p.useSeparateProjectionVolume.boolValue;
}
#region Field Drawers

8
ScriptableRenderPipeline/HDRenderPipeline/Editor/Lighting/HDReflectionProbeEditor.cs


m_SerializedReflectionProbe = new SerializedReflectionProbe(serializedObject, m_AdditionalDataSerializedObject);
m_UIState.Reset(
this,
Repaint,
m_SerializedReflectionProbe.mode.intValue,
m_SerializedReflectionProbe.influenceShape.intValue);
Repaint,
m_SerializedReflectionProbe);
}
public override void OnInspectorGUI()

var s = m_UIState;
var p = m_SerializedReflectionProbe;
Draw(k_PrimarySection, s, p, this);
k_PrimarySection.Draw(s, p, this);
k_SeparateProjectionVolumeSection.Draw(s, p, this);
PerformOperations(s, p, this);

正在加载...
取消
保存