浏览代码

Merge pull request #1622 from Unity-Technologies/feature/HDReflectionProbe-refactor-inspector

Feature/hd reflection probe refactor inspector
/main
GitHub 6 年前
当前提交
73e0bd06
共有 18 个文件被更改,包括 1420 次插入442 次删除
  1. 83
      com.unity.render-pipelines.core/CoreRP/Editor/CoreEditorUtils.cs
  2. 378
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDReflectionProbeEditor.Handles.cs
  3. 337
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDReflectionProbeUI.Drawers.cs
  4. 38
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDReflectionProbeUI.cs
  5. 84
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/PlanarReflectionProbeUI.Drawers.cs
  6. 8
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/PlanarReflectionProbeUI.cs
  7. 43
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/SerializedHDReflectionProbe.cs
  8. 127
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/Volume/InfluenceVolumeUI.Drawers.cs
  9. 24
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/Volume/InfluenceVolumeUI.Gizmos.cs
  10. 171
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/Volume/InfluenceVolumeUI.Handles.cs
  11. 55
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/Volume/InfluenceVolumeUI.cs
  12. 49
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/Volume/SerializedInfluenceVolume.cs
  13. 12
      com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/HDAdditionalReflectionData.cs
  14. 12
      com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/Volumes/InfluenceVolume.cs
  15. 8
      com.unity.render-pipelines.core/CoreRP/Tool.meta
  16. 11
      com.unity.render-pipelines.core/CoreRP/Tool/Gizmo6FacesBox.cs.meta
  17. 422
      com.unity.render-pipelines.core/CoreRP/Tool/Gizmo6FacesBox.cs

83
com.unity.render-pipelines.core/CoreRP/Editor/CoreEditorUtils.cs


return group.isExpanded;
}
static readonly GUIContent[] k_DrawVector6Slider_LabelPositives =
static readonly GUIContent[] k_DrawVector6_Label =
new GUIContent("+X"),
new GUIContent("+Y"),
new GUIContent("+Z"),
};
static readonly GUIContent[] k_DrawVector6Slider_LabelNegatives =
{
new GUIContent("-X"),
new GUIContent("-Y"),
new GUIContent("-Z"),
new GUIContent("X"),
new GUIContent("Y"),
new GUIContent("Z"),
public static void DrawVector6Slider(GUIContent label, SerializedProperty positive, SerializedProperty negative, Vector3 min, Vector3 max)
public static void DrawVector6(GUIContent label, SerializedProperty positive, SerializedProperty negative, Vector3 min, Vector3 max, Color[][] colors = null)
if (colors != null && (colors.Length != 2 || colors[0].Length != 3 || colors[1].Length != 3))
throw new System.ArgumentException("Colors must be a 2x3 array.");
EditorGUILayout.LabelField(label);
if(label != GUIContent.none)
EditorGUILayout.LabelField(label);
v = DrawVector3Slider(rect, k_DrawVector6Slider_LabelPositives, v, min, max);
v = DrawVector3(rect, k_DrawVector6_Label, v, min, max, false, colors == null ? null : colors[0]);
if (EditorGUI.EndChangeCheck())
positive.vector3Value = v;

v = negative.vector3Value;
EditorGUI.BeginChangeCheck();
v = DrawVector3Slider(rect, k_DrawVector6Slider_LabelNegatives, v, min, max);
v = DrawVector3(rect, k_DrawVector6_Label, v, min, max, true, colors == null ? null : colors[1]);
if (EditorGUI.EndChangeCheck())
negative.vector3Value = v;
--EditorGUI.indentLevel;

static Vector3 DrawVector3Slider(Rect rect, GUIContent[] labels, Vector3 value, Vector3 min, Vector3 max)
static Vector3 DrawVector3(Rect rect, GUIContent[] labels, Vector3 value, Vector3 min, Vector3 max, bool addMinusPrefix, Color[] colors)
// Use a corrected width due to the hacks used for layouting the slider properly below
rect.width -= 20;
var fieldWidth = rect.width / 3f;
float[] multifloat = new float[] { value.x, value.y, value.z };
rect = EditorGUI.IndentedRect(rect);
float fieldWidth = rect.width / 3f;
EditorGUI.BeginChangeCheck();
EditorGUI.MultiFloatField(rect, labels, multifloat);
if(EditorGUI.EndChangeCheck())
{
value.x = Mathf.Max(Mathf.Min(multifloat[0], max.x), min.x);
value.y = Mathf.Max(Mathf.Min(multifloat[1], max.y), min.y);
value.z = Mathf.Max(Mathf.Min(multifloat[2], max.z), min.z);
}
//Suffix is a hack as sublabel only work with 1 character
if(addMinusPrefix)
{
Rect suffixRect = new Rect(rect.x-33, rect.y, 100, rect.height);
for(int i = 0; i < 3; ++i)
{
EditorGUI.LabelField(suffixRect, "-");
suffixRect.x += fieldWidth + .5f;
}
}
for (var i = 0; i < 3; ++i)
//Color is a hack as nothing is done to handle this at the moment
if(colors != null)
var c = new Rect(rect.x + fieldWidth * i, rect.y, fieldWidth, rect.height);
var labelRect = new Rect(c.x, c.y, k_DrawVector6Slider_LabelSize, c.height);
var sliderRect = new Rect(labelRect.x + labelRect.width, c.y, c.width - k_DrawVector6Slider_LabelSize - k_DrawVector6Slider_FieldSize + 45, c.height);
var fieldRect = new Rect(sliderRect.x + sliderRect.width - 25, c.y, k_DrawVector6Slider_FieldSize, c.height);
EditorGUI.LabelField(labelRect, labels[i]);
value[i] = GUI.HorizontalSlider(sliderRect, value[i], min[i], max[i]);
value[i] = EditorGUI.FloatField(fieldRect, value[i]);
if (colors.Length != 3)
throw new System.ArgumentException("colors must have 3 elements.");
Rect suffixRect = new Rect(rect.x - 23, rect.y, 100, rect.height);
GUIStyle colorMark = new GUIStyle(EditorStyles.label);
colorMark.normal.textColor = colors[0];
EditorGUI.LabelField(suffixRect, "|", colorMark);
suffixRect.x += 1;
EditorGUI.LabelField(suffixRect, "|", colorMark);
suffixRect.x += fieldWidth - .5f;
colorMark.normal.textColor = colors[1];
EditorGUI.LabelField(suffixRect, "|", colorMark);
suffixRect.x += 1;
EditorGUI.LabelField(suffixRect, "|", colorMark);
suffixRect.x += fieldWidth + .5f;
colorMark.normal.textColor = colors[2];
EditorGUI.LabelField(suffixRect, "|", colorMark);
suffixRect.x += 1;
EditorGUI.LabelField(suffixRect, "|", colorMark);
}
return value;
}

378
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDReflectionProbeEditor.Handles.cs


using UnityEngine.Experimental.Rendering;
using UnityEngine.Experimental.Rendering.HDPipeline;
using UnityEngine.Rendering;
using UnityEngine.Experimental.Rendering;
namespace UnityEditor.Experimental.Rendering
{

internal static Color k_GizmoThemeColorDisabled = new Color(0x99 / 255f, 0x89 / 255f, 0x59 / 255f, 0x10 / 255f);
internal static Color k_GizmoThemeColorDisabledFace = new Color(0x99 / 255f, 0x89 / 255f, 0x59 / 255f, 0x10 / 255f);
internal static readonly Color[][] k_handlesColor = new Color[][]
{
new Color[]
{
Color.red,
Color.green,
Color.blue
},
new Color[]
{
new Color(.5f, 0f, 0f, 1f),
new Color(0f, .5f, 0f, 1f),
new Color(0f, 0f, .5f, 1f)
}
};
void OnSceneGUI()
{
var s = m_UIState;

static void Handle_InfluenceFadeEditing(HDReflectionProbeUI s, SerializedHDReflectionProbe sp, Editor o, InfluenceType influenceType)
{
BoxBoundsHandle blendBox;
Gizmo6FacesBoxContained alternativeBlendBox;
SphereBoundsHandle sphereHandle;
Vector3 probeBlendDistancePositive, probeBlendDistanceNegative;
Color color;

case InfluenceType.Standard:
{
blendBox = s.boxBlendHandle;
sphereHandle = s.sphereBlendHandle;
probeBlendDistancePositive = sp.targetData.blendDistancePositive;
probeBlendDistanceNegative = sp.targetData.blendDistanceNegative;
color = k_GizmoThemeColorInfluenceBlend;
break;
}
{
alternativeBlendBox = s.alternativeBoxBlendHandle;
sphereHandle = s.sphereBlendHandle;
probeBlendDistancePositive = sp.targetData.blendDistancePositive;
probeBlendDistanceNegative = sp.targetData.blendDistanceNegative;
color = k_GizmoThemeColorInfluenceBlend;
break;
}
{
blendBox = s.boxBlendNormalHandle;
sphereHandle = s.sphereBlendNormalHandle;
probeBlendDistancePositive = sp.targetData.blendNormalDistancePositive;
probeBlendDistanceNegative = sp.targetData.blendNormalDistanceNegative;
color = k_GizmoThemeColorInfluenceNormalBlend;
break;
}
{
alternativeBlendBox = s.alternativeBoxBlendNormalHandle;
sphereHandle = s.sphereBlendNormalHandle;
probeBlendDistancePositive = sp.targetData.blendNormalDistancePositive;
probeBlendDistanceNegative = sp.targetData.blendNormalDistanceNegative;
color = k_GizmoThemeColorInfluenceNormalBlend;
break;
}
var mat = Handles.matrix;
var col = Handles.color;

case ShapeType.Box:
{
blendBox.center = sp.target.center - (probeBlendDistancePositive - probeBlendDistanceNegative) * 0.5f;
blendBox.size = sp.target.size - probeBlendDistancePositive - probeBlendDistanceNegative;
{
alternativeBlendBox.center = sp.target.center - (probeBlendDistancePositive - probeBlendDistanceNegative) * 0.5f;
alternativeBlendBox.size = sp.target.size - probeBlendDistancePositive - probeBlendDistanceNegative;
Handles.color = k_GizmoThemeColorExtent;
EditorGUI.BeginChangeCheck();
Handles.color = color;
blendBox.DrawHandle();
if (EditorGUI.EndChangeCheck())
{
Undo.RecordObject(sp.target, "Modified Reflection Probe Influence");
Undo.RecordObject(sp.targetData, "Modified Reflection Probe Influence");
alternativeBlendBox.container.center = sp.target.center;
alternativeBlendBox.container.size = sp.target.size;
EditorGUI.BeginChangeCheck();
alternativeBlendBox.DrawHandle();
if (EditorGUI.EndChangeCheck())
{
Undo.RecordObject(sp.target, "Modified Reflection Probe Influence");
Undo.RecordObject(sp.targetData, "Modified Reflection Probe Influence");
var center = sp.target.center;
var influenceSize = sp.target.size;
var center = sp.target.center;
var influenceSize = sp.target.size;
var diff = 2 * (blendBox.center - center);
var sum = influenceSize - blendBox.size;
var positive = (sum - diff) * 0.5f;
var negative = (sum + diff) * 0.5f;
var blendDistancePositive = Vector3.Max(Vector3.zero, Vector3.Min(positive, influenceSize));
var blendDistanceNegative = Vector3.Max(Vector3.zero, Vector3.Min(negative, influenceSize));
var diff = 2 * (alternativeBlendBox.center - center);
var sum = influenceSize - (alternativeBlendBox.size);
var positive = (sum - diff) * 0.5f;
var negative = (sum + diff) * 0.5f;
var blendDistancePositive = Vector3.Max(Vector3.zero, Vector3.Min(positive, influenceSize));
var blendDistanceNegative = Vector3.Max(Vector3.zero, Vector3.Min(negative, influenceSize));
probeBlendDistancePositive = blendDistancePositive;
probeBlendDistanceNegative = blendDistanceNegative;
probeBlendDistancePositive = blendDistancePositive;
probeBlendDistanceNegative = blendDistanceNegative;
ApplyConstraintsOnTargets(s, sp, o);
ApplyConstraintsOnTargets(s, sp, o);
EditorUtility.SetDirty(sp.target);
EditorUtility.SetDirty(sp.targetData);
EditorUtility.SetDirty(sp.target);
EditorUtility.SetDirty(sp.targetData);
}
break;
break;
}
{
sphereHandle.center = sp.target.center;
sphereHandle.radius = Mathf.Clamp(sp.targetData.influenceSphereRadius - probeBlendDistancePositive.x, 0, sp.targetData.influenceSphereRadius);
{
sphereHandle.center = sp.target.center;
sphereHandle.radius = Mathf.Clamp(sp.targetData.influenceSphereRadius - probeBlendDistancePositive.x, 0, sp.targetData.influenceSphereRadius);
Handles.color = k_GizmoThemeColorExtent;
EditorGUI.BeginChangeCheck();
Handles.color = color;
sphereHandle.DrawHandle();
if (EditorGUI.EndChangeCheck())
{
Undo.RecordObject(sp.target, "Modified Reflection influence volume");
Undo.RecordObject(sp.targetData, "Modified Reflection influence volume");
Handles.color = k_GizmoThemeColorExtent;
EditorGUI.BeginChangeCheck();
Handles.color = color;
sphereHandle.DrawHandle();
if (EditorGUI.EndChangeCheck())
{
Undo.RecordObject(sp.target, "Modified Reflection influence volume");
Undo.RecordObject(sp.targetData, "Modified Reflection influence volume");
var influenceRadius = sp.targetData.influenceSphereRadius;
var blendRadius = sphereHandle.radius;
var influenceRadius = sp.targetData.influenceSphereRadius;
var blendRadius = sphereHandle.radius;
var blendDistance = Mathf.Clamp(influenceRadius - blendRadius, 0, influenceRadius);
var blendDistance = Mathf.Clamp(influenceRadius - blendRadius, 0, influenceRadius);
probeBlendDistancePositive = Vector3.one * blendDistance;
probeBlendDistanceNegative = probeBlendDistancePositive;
probeBlendDistancePositive = Vector3.one * blendDistance;
probeBlendDistanceNegative = probeBlendDistancePositive;
ApplyConstraintsOnTargets(s, sp, o);
ApplyConstraintsOnTargets(s, sp, o);
EditorUtility.SetDirty(sp.target);
EditorUtility.SetDirty(sp.targetData);
EditorUtility.SetDirty(sp.target);
EditorUtility.SetDirty(sp.targetData);
}
break;
break;
}
}
Handles.matrix = mat;
Handles.color = col;

{
default:
case InfluenceType.Standard:
{
sp.targetData.blendDistancePositive = probeBlendDistancePositive;
sp.targetData.blendDistanceNegative = probeBlendDistanceNegative;
break;
}
{
sp.blendDistancePositive.vector3Value = probeBlendDistancePositive;
sp.blendDistanceNegative.vector3Value = probeBlendDistanceNegative;
//save advanced/simplified saved data
if (sp.editorAdvancedModeEnabled.boolValue)
{
sp.editorAdvancedModeBlendDistancePositive.vector3Value = probeBlendDistancePositive;
sp.editorAdvancedModeBlendDistanceNegative.vector3Value = probeBlendDistanceNegative;
}
else
{
sp.editorSimplifiedModeBlendDistance.floatValue = probeBlendDistancePositive.x;
}
break;
}
{
sp.targetData.blendNormalDistancePositive = probeBlendDistancePositive;
sp.targetData.blendNormalDistanceNegative = probeBlendDistanceNegative;
break;
}
{
sp.blendNormalDistancePositive.vector3Value = probeBlendDistancePositive;
sp.blendNormalDistanceNegative.vector3Value = probeBlendDistanceNegative;
//save advanced/simplified saved data
if (sp.editorAdvancedModeEnabled.boolValue)
{
sp.editorAdvancedModeBlendNormalDistancePositive.vector3Value = probeBlendDistancePositive;
sp.editorAdvancedModeBlendNormalDistanceNegative.vector3Value = probeBlendDistanceNegative;
}
else
{
sp.editorSimplifiedModeBlendNormalDistance.floatValue = probeBlendDistancePositive.x;
}
break;
}
sp.Apply();
}
static void Handle_InfluenceEditing(HDReflectionProbeUI s, SerializedHDReflectionProbe sp, Editor o)

switch ((ShapeType)sp.influenceShape.enumValueIndex)
{
case ShapeType.Box:
{
s.boxInfluenceHandle.center = sp.target.center;
s.boxInfluenceHandle.size = sp.target.size;
Handles.color = k_GizmoThemeColorExtent;
EditorGUI.BeginChangeCheck();
s.boxInfluenceHandle.DrawHandle();
if (EditorGUI.EndChangeCheck())
Undo.RecordObject(sp.target, "Modified Reflection Probe AABB");
Undo.RecordObject(sp.targetData, "Modified Reflection Probe AABB");
s.alternativeBoxInfluenceHandle.center = sp.target.center;
s.alternativeBoxInfluenceHandle.size = sp.target.size;
var center = s.boxInfluenceHandle.center;
var size = s.boxInfluenceHandle.size;
EditorGUI.BeginChangeCheck();
s.alternativeBoxInfluenceHandle.DrawHandle();
if (EditorGUI.EndChangeCheck())
{
Undo.RecordObject(sp.target, "Modified Reflection Probe AABB");
Undo.RecordObject(sp.targetData, "Modified Reflection Probe AABB");
HDReflectionProbeEditorUtility.ValidateAABB(sp.target, ref center, ref size);
Vector3 center;
Vector3 size;
center = s.alternativeBoxInfluenceHandle.center;
size = s.alternativeBoxInfluenceHandle.size;
sp.target.center = center;
sp.target.size = size;
HDReflectionProbeEditorUtility.ValidateAABB(sp.target, ref center, ref size);
ApplyConstraintsOnTargets(s, sp, o);
sp.target.center = center;
sp.target.size = size;
EditorUtility.SetDirty(sp.target);
EditorUtility.SetDirty(sp.targetData);
//ApplyConstraintsOnTargets(s, sp, o);
EditorUtility.SetDirty(sp.target);
EditorUtility.SetDirty(sp.targetData);
}
break;
break;
}
{
s.sphereInfluenceHandle.center = sp.target.center;
s.sphereInfluenceHandle.radius = sp.targetData.influenceSphereRadius;
{
s.sphereInfluenceHandle.center = sp.target.center;
s.sphereInfluenceHandle.radius = sp.targetData.influenceSphereRadius;
Handles.color = k_GizmoThemeColorExtent;
EditorGUI.BeginChangeCheck();
s.sphereInfluenceHandle.DrawHandle();
if (EditorGUI.EndChangeCheck())
{
Undo.RecordObject(sp.target, "Modified Reflection Probe AABB");
Undo.RecordObject(sp.targetData, "Modified Reflection Probe AABB");
Handles.color = k_GizmoThemeColorExtent;
EditorGUI.BeginChangeCheck();
s.sphereInfluenceHandle.DrawHandle();
if (EditorGUI.EndChangeCheck())
{
Undo.RecordObject(sp.target, "Modified Reflection Probe AABB");
Undo.RecordObject(sp.targetData, "Modified Reflection Probe AABB");
var center = sp.target.center;
var influenceRadius = s.sphereInfluenceHandle.radius;
var radius = Vector3.one * influenceRadius;
var center = sp.target.center;
var influenceRadius = s.sphereInfluenceHandle.radius;
var radius = Vector3.one * influenceRadius;
HDReflectionProbeEditorUtility.ValidateAABB(sp.target, ref center, ref radius);
influenceRadius = radius.x;
HDReflectionProbeEditorUtility.ValidateAABB(sp.target, ref center, ref radius);
influenceRadius = radius.x;
sp.targetData.influenceSphereRadius = influenceRadius;
sp.targetData.influenceSphereRadius = influenceRadius;
ApplyConstraintsOnTargets(s, sp, o);
//ApplyConstraintsOnTargets(s, sp, o);
EditorUtility.SetDirty(sp.target);
EditorUtility.SetDirty(sp.targetData);
EditorUtility.SetDirty(sp.target);
EditorUtility.SetDirty(sp.targetData);
}
break;
break;
}
}
Handles.matrix = mat;
Handles.color = col;

var reflectionData = reflectionProbe.GetComponent<HDAdditionalReflectionData>();
Gizmos_Influence(reflectionProbe, reflectionData, null, false);
//Gizmos_Influence(reflectionProbe, reflectionData, e, false);
Gizmos_InfluenceFade(reflectionProbe, reflectionData, null, InfluenceType.Standard, false);
Gizmos_InfluenceFade(reflectionProbe, reflectionData, null, InfluenceType.Normal, false);

HDReflectionProbeEditorUtility.ChangeVisibility(reflectionProbe, false);
}
static void Gizmos_InfluenceFade(ReflectionProbe p, HDAdditionalReflectionData a, Editor e, InfluenceType type, bool isEdit)
static void Gizmos_InfluenceFade(ReflectionProbe p, HDAdditionalReflectionData a, HDReflectionProbeEditor e, InfluenceType type, bool isEdit)
Gizmo6FacesBoxContained box;
Vector3 boxCenterOffset;
Vector3 boxSizeOffset;
float sphereRadiusOffset;

default:
case InfluenceType.Standard:
{
boxCenterOffset = a.boxBlendCenterOffset;
boxSizeOffset = a.boxBlendSizeOffset;
sphereRadiusOffset = a.sphereBlendRadiusOffset;
color = isEdit ? k_GizmoThemeColorInfluenceBlendFace : k_GizmoThemeColorInfluenceBlend;
break;
}
{
box = e != null ? e.m_UIState.alternativeBoxBlendHandle : null;
boxCenterOffset = a.boxBlendCenterOffset;
boxSizeOffset = a.boxBlendSizeOffset;
sphereRadiusOffset = a.sphereBlendRadiusOffset;
color = isEdit ? k_GizmoThemeColorInfluenceBlendFace : k_GizmoThemeColorInfluenceBlend;
break;
}
{
boxCenterOffset = a.boxBlendNormalCenterOffset;
boxSizeOffset = a.boxBlendNormalSizeOffset;
sphereRadiusOffset = a.sphereBlendNormalRadiusOffset;
color = isEdit ? k_GizmoThemeColorInfluenceNormalBlendFace : k_GizmoThemeColorInfluenceNormalBlend;
break;
}
{
box = e != null ? e.m_UIState.alternativeBoxBlendNormalHandle : null;
boxCenterOffset = a.boxBlendNormalCenterOffset;
boxSizeOffset = a.boxBlendNormalSizeOffset;
sphereRadiusOffset = a.sphereBlendNormalRadiusOffset;
color = isEdit ? k_GizmoThemeColorInfluenceNormalBlendFace : k_GizmoThemeColorInfluenceNormalBlend;
break;
}
}
Gizmos.matrix = HDReflectionProbeEditorUtility.GetLocalSpace(p);

{
Gizmos.color = color;
if (isEdit)
Gizmos.DrawCube(p.center + boxCenterOffset, p.size + boxSizeOffset);
else
Gizmos.DrawWireCube(p.center + boxCenterOffset, p.size + boxSizeOffset);
break;
}
{
Gizmos.color = color;
if(e != null) // e == null may occure when editor have still not been created at selection while the tool is not used for this part
{
box.DrawHull(isEdit);
}
else
{
if (isEdit)
Gizmos.DrawCube(p.center + boxCenterOffset, p.size + boxSizeOffset);
else
Gizmos.DrawWireCube(p.center + boxCenterOffset, p.size + boxSizeOffset);
}
break;
}
{
Gizmos.color = color;
if (isEdit)
Gizmos.DrawSphere(p.center, a.influenceSphereRadius + sphereRadiusOffset);
else
Gizmos.DrawWireSphere(p.center, a.influenceSphereRadius + sphereRadiusOffset);
break;
}
{
Gizmos.color = color;
if (isEdit)
Gizmos.DrawSphere(p.center, a.influenceSphereRadius + sphereRadiusOffset);
else
Gizmos.DrawWireSphere(p.center, a.influenceSphereRadius + sphereRadiusOffset);
break;
}
}
Gizmos.matrix = mat;

static void Gizmos_Influence(ReflectionProbe p, HDAdditionalReflectionData a, Editor e, bool isEdit)
static void Gizmos_Influence(ReflectionProbe p, HDAdditionalReflectionData a, HDReflectionProbeEditor e, bool isEdit)
{
var col = Gizmos.color;
var mat = Gizmos.matrix;

{
case ShapeType.Box:
{
Gizmos.color = isEdit ? k_GizmoThemeColorExtentFace : k_GizmoThemeColorExtent;
if (isEdit)
Gizmos.DrawCube(p.center, p.size);
else
Gizmos.DrawWireCube(p.center, p.size);
break;
}
{
Gizmos.color = k_GizmoThemeColorExtentFace;
e.m_UIState.alternativeBoxInfluenceHandle.DrawHull(isEdit);
break;
}
{
Gizmos.color = k_GizmoThemeColorExtentFace;
if (isEdit)
Gizmos.DrawSphere(p.center, a.influenceSphereRadius);
else
Gizmos.DrawWireSphere(p.center, a.influenceSphereRadius);
break;
}
{
Gizmos.color = k_GizmoThemeColorExtentFace;
if (isEdit)
Gizmos.DrawSphere(p.center, a.influenceSphereRadius);
else
Gizmos.DrawWireSphere(p.center, a.influenceSphereRadius);
break;
}
}
Gizmos.matrix = mat;

337
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDReflectionProbeUI.Drawers.cs


Inspector = new[]
{
SectionPrimarySettings,
SectionProxyVolumeSettings,
SectionSeparateProjectionVolumeSettings,
//SectionSeparateProjectionVolumeSettings,
SectionInfluenceProxyMismatch,
SectionCaptureSettings,
SectionAdditionalSettings,
ButtonBake

public static readonly CED.IDrawer[] Inspector;
public static readonly CED.IDrawer SectionPrimarySettings = CED.Group(
CED.Action(Drawer_Toolbar),
CED.space,
CED.space,
),
CED.space,
CED.Action(Drawer_InfluenceShape),
//CED.Action(Drawer_IntensityMultiplier),
CED.space,
CED.Action(Drawer_Toolbar),
CED.space,
CED.Action((s, d, o) => EditorGUILayout.PropertyField(d.proxyVolumeComponent, _.GetContent("Proxy Volume")))
)
);
public static readonly CED.IDrawer SectionProxyVolumeSettings = CED.FoldoutGroup(
"Proxy Volume",
(s, p, o) => s.isSectionExpandedProxyVolume,
FoldoutOption.Indent,
CED.Action(Drawer_ProxyVolume)
"Influence volume settings",
"Influence Volume",
CED.FadeGroup(
(s, p, o, i) => s.IsSectionExpandedShape((ShapeType)i),
FadeOption.None,
CED.Action(Drawer_InfluenceBoxSettings), // Box
CED.Action(Drawer_InfluenceSphereSettings) // Sphere
)/*,
CED.Action(Drawer_UseSeparateProjectionVolume)*/
CED.Action(Drawer_InfluenceAdvancedSwitch),
CED.space,
CED.Action(Drawer_InfluenceShape),
CED.space,
CED.Action(Drawer_InfluenceAreas),
CED.space,
CED.Action(Drawer_InfluenceSettings)
public static readonly CED.IDrawer SectionSeparateProjectionVolumeSettings = CED.FadeGroup(
(s, p, o, i) => s.isSectionExpandedSeparateProjection,
FadeOption.None,
CED.FoldoutGroup(
"Reprojection volume settings",
(s, p, o) => s.isSectionExpandedSeparateProjection,
FoldoutOption.Indent,
CED.FadeGroup(
(s, p, o, i) => s.IsSectionExpandedShape((ShapeType)i),
FadeOption.None,
CED.Action(Drawer_ProjectionBoxSettings), // Box
CED.Action(Drawer_ProjectionSphereSettings) // Sphere
)
)
);
public static readonly CED.IDrawer SectionInfluenceProxyMismatch = CED.Action(Drawer_InfluenceProxyMissmatch);
"Capture settings",
"Capture Settings",
(s, p, o) => s.isSectionExpandedCaptureSettings,
FoldoutOption.Indent,
CED.Action(Drawer_CaptureSettings)

"Additional settings",
"Artistic Settings",
(s, p, o) => s.isSectionExpandedAdditional,
FoldoutOption.Indent,
CED.Action(Drawer_AdditionalSettings)

static void Drawer_AdditionalSettings(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner)
{
EditorGUILayout.PropertyField(p.weight);
EditorGUILayout.PropertyField(p.weight, CoreEditorUtils.GetContent("Influence Volume Weight|Blending weight to use while interpolating between influence volume. (Reminder: Sky is an Influence Volume too)."));
EditorGUILayout.PropertyField(p.multiplier);
EditorGUILayout.PropertyField(p.multiplier, CoreEditorUtils.GetContent("Multiplier|Tweeking option to enhance reflection."));
if (EditorGUI.EndChangeCheck())
p.multiplier.floatValue = Mathf.Max(0.0f, p.multiplier.floatValue);

EditorReflectionSystemGUI.DrawBakeButton((ReflectionProbeMode)p.mode.intValue, p.target);
}
static void Drawer_ProxyVolume(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner)
{
EditorGUILayout.PropertyField(p.proxyVolumeComponent, _.GetContent("Proxy Volume"));
if (p.proxyVolumeComponent.objectReferenceValue == null)
{
EditorGUILayout.HelpBox(
"When no Proxy setted, Influence shape will be used as Proxy shape too.",
MessageType.Info,
true
);
}
}
static void Drawer_InfluenceProxyMissmatch(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner)
{
if (p.proxyVolumeComponent.objectReferenceValue != null)
{
var proxy = (ReflectionProxyVolumeComponent)p.proxyVolumeComponent.objectReferenceValue;
if ((int)proxy.proxyVolume.shapeType != p.influenceShape.enumValueIndex)
EditorGUILayout.HelpBox(
"Proxy volume and influence volume have different shape types, this is not supported.",
MessageType.Error,
true
);
}
}
bool advanced = p.editorAdvancedModeEnabled.boolValue;
CoreEditorUtils.DrawVector6Slider(
CoreEditorUtils.GetContent("Blend Distance|Area around the probe where it is blended with other probes. Only used in deferred probes."),
p.blendDistancePositive, p.blendDistanceNegative, Vector3.zero, maxBlendDistance);
CoreEditorUtils.DrawVector6Slider(
CoreEditorUtils.GetContent("Blend Normal Distance|Area around the probe where the normals influence the probe. Only used in deferred probes."),
p.blendNormalDistancePositive, p.blendNormalDistanceNegative, Vector3.zero, maxBlendDistance);
EditorGUILayout.BeginHorizontal();
Drawer_AdvancedBlendDistance(
p,
false,
maxBlendDistance,
CoreEditorUtils.GetContent("Blend Distance|Area around the probe where it is blended with other probes. Only used in deferred probes.")
);
if (GUILayout.Button(toolbar_Contents[1], GUILayout.ExpandHeight(true), GUILayout.Width(28f), GUILayout.MinHeight(22f), GUILayout.MaxHeight((advanced ? 3 : 1) * (EditorGUIUtility.singleLineHeight + 3))))
{
EditMode.ChangeEditMode(k_Toolbar_SceneViewEditModes[1], GetBoundsGetter(p)(), owner);
}
EditorGUILayout.EndHorizontal();
CoreEditorUtils.DrawVector6Slider(
CoreEditorUtils.GetContent("Face fade|Fade faces of the cubemap."),
p.boxSideFadePositive, p.boxSideFadeNegative, Vector3.zero, Vector3.one);
EditorGUILayout.BeginHorizontal();
Drawer_AdvancedBlendDistance(
p,
true,
maxBlendDistance,
CoreEditorUtils.GetContent("Blend Normal Distance|Area around the probe where the normals influence the probe. Only used in deferred probes.")
);
if (GUILayout.Button(toolbar_Contents[2], GUILayout.ExpandHeight(true), GUILayout.Width(28f), GUILayout.MinHeight(22f), GUILayout.MaxHeight((advanced ? 3 : 1) * (EditorGUIUtility.singleLineHeight + 3))))
{
EditMode.ChangeEditMode(k_Toolbar_SceneViewEditModes[2], GetBoundsGetter(p)(), owner);
}
EditorGUILayout.EndHorizontal();
EditorGUILayout.Space();
if (advanced)
{
CoreEditorUtils.DrawVector6(
CoreEditorUtils.GetContent("Face fade|Fade faces of the cubemap."),
p.boxSideFadePositive, p.boxSideFadeNegative, Vector3.zero, Vector3.one, HDReflectionProbeEditor.k_handlesColor);
}
}
EditorGUI.BeginChangeCheck();
EditorGUILayout.PropertyField(p.boxSize, CoreEditorUtils.GetContent("Box Size|The size of the box in which the reflections will be applied to objects. The value is not affected by the Transform of the Game Object."));
EditorGUILayout.PropertyField(p.boxOffset, CoreEditorUtils.GetContent("Box Offset|The center of the box in which the reflections will be applied to objects. The value is relative to the position of the Game Object."));
EditorGUILayout.PropertyField(p.boxProjection, CoreEditorUtils.GetContent("Box Projection|Box projection causes reflections to appear to change based on the object's position within the probe's box, while still using a single probe as the source of the reflection. This works well for reflections on objects that are moving through enclosed spaces such as corridors and rooms. Setting box projection to False and the cubemap reflection will be treated as coming from infinitely far away. Note that this feature can be globally disabled from Graphics Settings -> Tier Settings"));
static void Drawer_AdvancedBlendDistance(SerializedHDReflectionProbe p, bool isNormal, Vector3 maxBlendDistance, GUIContent content)
{
SerializedProperty blendDistancePositive = isNormal ? p.blendNormalDistancePositive : p.blendDistancePositive;
SerializedProperty blendDistanceNegative = isNormal ? p.blendNormalDistanceNegative : p.blendDistanceNegative;
SerializedProperty editorAdvancedModeBlendDistancePositive = isNormal ? p.editorAdvancedModeBlendNormalDistancePositive : p.editorAdvancedModeBlendDistancePositive;
SerializedProperty editorAdvancedModeBlendDistanceNegative = isNormal ? p.editorAdvancedModeBlendNormalDistanceNegative : p.editorAdvancedModeBlendDistanceNegative;
SerializedProperty editorSimplifiedModeBlendDistance = isNormal ? p.editorSimplifiedModeBlendNormalDistance : p.editorSimplifiedModeBlendDistance;
Vector3 bdp = blendDistancePositive.vector3Value;
Vector3 bdn = blendDistanceNegative.vector3Value;
if (EditorGUI.EndChangeCheck())
EditorGUILayout.BeginVertical();
if (p.editorAdvancedModeEnabled.boolValue)
var center = p.boxOffset.vector3Value;
var size = p.boxSize.vector3Value;
if (HDReflectionProbeEditorUtility.ValidateAABB(p.target, ref center, ref size))
EditorGUI.BeginChangeCheck();
CoreEditorUtils.DrawVector6(
content,
editorAdvancedModeBlendDistancePositive, editorAdvancedModeBlendDistanceNegative, Vector3.zero, maxBlendDistance, HDReflectionProbeEditor.k_handlesColor);
if(EditorGUI.EndChangeCheck())
{
blendDistancePositive.vector3Value = editorAdvancedModeBlendDistancePositive.vector3Value;
blendDistanceNegative.vector3Value = editorAdvancedModeBlendDistanceNegative.vector3Value;
p.Apply();
}
}
else
{
float distance = editorSimplifiedModeBlendDistance.floatValue;
EditorGUI.BeginChangeCheck();
distance = EditorGUILayout.FloatField(content, distance);
if (EditorGUI.EndChangeCheck())
p.boxOffset.vector3Value = center;
p.boxSize.vector3Value = size;
Vector3 decal = Vector3.one * distance;
bdp.x = Mathf.Clamp(decal.x, 0f, maxBlendDistance.x);
bdp.y = Mathf.Clamp(decal.y, 0f, maxBlendDistance.y);
bdp.z = Mathf.Clamp(decal.z, 0f, maxBlendDistance.z);
bdn.x = Mathf.Clamp(decal.x, 0f, maxBlendDistance.x);
bdn.y = Mathf.Clamp(decal.y, 0f, maxBlendDistance.y);
bdn.z = Mathf.Clamp(decal.z, 0f, maxBlendDistance.z);
blendDistancePositive.vector3Value = bdp;
blendDistanceNegative.vector3Value = bdn;
editorSimplifiedModeBlendDistance.floatValue = distance;
p.Apply();
GUILayout.EndVertical();
}
static void Drawer_InfluenceSphereSettings(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner)

var blendDistance = p.blendDistancePositive.vector3Value.x;
EditorGUILayout.BeginHorizontal();
EditorGUI.BeginChangeCheck();
EditorGUI.showMixedValue = p.blendDistancePositive.hasMultipleDifferentValues;
blendDistance = EditorGUILayout.Slider(CoreEditorUtils.GetContent("Blend Distance|Area around the probe where it is blended with other probes. Only used in deferred probes."), blendDistance, 0, maxBlendDistance);

p.blendDistanceNegative.vector3Value = Vector3.one * blendDistance;
}
if (GUILayout.Button(toolbar_Contents[1], GUILayout.Width(28f), GUILayout.Height(EditorGUIUtility.singleLineHeight + 3)))
{
EditMode.ChangeEditMode(k_Toolbar_SceneViewEditModes[1], GetBoundsGetter(p)(), owner);
}
EditorGUILayout.EndHorizontal();
EditorGUILayout.BeginHorizontal();
EditorGUI.BeginChangeCheck();
EditorGUI.showMixedValue = p.blendNormalDistancePositive.hasMultipleDifferentValues;
blendNormalDistance = EditorGUILayout.Slider(CoreEditorUtils.GetContent("Blend Normal Distance|Area around the probe where the normals influence the probe. Only used in deferred probes."), blendNormalDistance, 0, maxBlendDistance);

p.blendNormalDistanceNegative.vector3Value = Vector3.one * blendNormalDistance;
}
if (GUILayout.Button(toolbar_Contents[2], GUILayout.Width(28f), GUILayout.Height(EditorGUIUtility.singleLineHeight + 3)))
{
EditMode.ChangeEditMode(k_Toolbar_SceneViewEditModes[2], GetBoundsGetter(p)(), owner);
}
EditorGUILayout.EndHorizontal();
EditorGUILayout.PropertyField(p.influenceSphereRadius, CoreEditorUtils.GetContent("Radius"));
EditorGUILayout.PropertyField(p.boxOffset, CoreEditorUtils.GetContent("Sphere Offset|The center of the sphere in which the reflections will be applied to objects. The value is relative to the position of the Game Object."));
EditorGUILayout.PropertyField(p.boxProjection, CoreEditorUtils.GetContent("Sphere Projection|Sphere projection causes reflections to appear to change based on the object's position within the probe's sphere, while still using a single probe as the source of the reflection. This works well for reflections on objects that are moving through enclosed spaces such as corridors and rooms. Setting sphere projection to False and the cubemap reflection will be treated as coming from infinitely far away. Note that this feature can be globally disabled from Graphics Settings -> Tier Settings"));
}
#endregion
#region Projection Volume
static void Drawer_UseSeparateProjectionVolume(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner)
{
EditorGUILayout.PropertyField(p.useSeparateProjectionVolume);
s.isSectionExpandedSeparateProjection.target = p.useSeparateProjectionVolume.boolValue;
}
static void Drawer_ProjectionBoxSettings(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner)
{
EditorGUILayout.PropertyField(p.boxReprojectionVolumeSize);
EditorGUILayout.PropertyField(p.boxReprojectionVolumeCenter);
}
static void Drawer_ProjectionSphereSettings(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner)
{
EditorGUILayout.PropertyField(p.sphereReprojectionVolumeRadius);
}
#endregion

s.SetModeTarget(p.mode.intValue);
foreach (var targetObject in p.so.targetObjects)
HDReflectionProbeEditorUtility.ResetProbeSceneTextureInMaterial((ReflectionProbe)targetObject);
}
}
static void Drawer_InfluenceAdvancedSwitch(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner)
{
using (new EditorGUILayout.HorizontalScope())
{
GUILayout.FlexibleSpace();
bool advanced = p.editorAdvancedModeEnabled.boolValue;
advanced = !GUILayout.Toggle(!advanced, CoreEditorUtils.GetContent("Normal|Normal parameters mode (only change for box shape)."), EditorStyles.miniButtonLeft, GUILayout.Width(60f), GUILayout.ExpandWidth(false));
advanced = GUILayout.Toggle(advanced, CoreEditorUtils.GetContent("Advanced|Advanced parameters mode (only change for box shape)."), EditorStyles.miniButtonRight, GUILayout.Width(60f), GUILayout.ExpandWidth(false));
s.alternativeBoxBlendHandle.allHandleControledByOne = s.alternativeBoxBlendNormalHandle.allHandleControledByOne = !advanced;
if (p.editorAdvancedModeEnabled.boolValue ^ advanced)
{
p.editorAdvancedModeEnabled.boolValue = advanced;
if (advanced)
{
p.blendDistancePositive.vector3Value = p.editorAdvancedModeBlendDistancePositive.vector3Value;
p.blendDistanceNegative.vector3Value = p.editorAdvancedModeBlendDistanceNegative.vector3Value;
p.blendNormalDistancePositive.vector3Value = p.editorAdvancedModeBlendNormalDistancePositive.vector3Value;
p.blendNormalDistanceNegative.vector3Value = p.editorAdvancedModeBlendNormalDistanceNegative.vector3Value;
}
else
{
p.blendDistanceNegative.vector3Value = p.blendDistancePositive.vector3Value = Vector3.one * p.editorSimplifiedModeBlendDistance.floatValue;
p.blendNormalDistanceNegative.vector3Value = p.blendNormalDistancePositive.vector3Value = Vector3.one * p.editorSimplifiedModeBlendNormalDistance.floatValue;
}
p.Apply();
}
}
}

if (EditorGUI.EndChangeCheck())
s.SetShapeTarget(p.influenceShape.intValue);
if (p.proxyVolumeComponent.objectReferenceValue != null)
switch ((ShapeType)p.influenceShape.enumValueIndex)
var proxy = (ReflectionProxyVolumeComponent)p.proxyVolumeComponent.objectReferenceValue;
if ((int)proxy.proxyVolume.shapeType != p.influenceShape.enumValueIndex)
EditorGUILayout.HelpBox(
"Proxy volume and influence volume have different shape types, this is not supported.",
MessageType.Error,
true
);
case ShapeType.Box:
Drawer_InfluenceShapeBoxSettings(s, p, owner);
break;
case ShapeType.Sphere:
Drawer_InfluenceShapeSphereSettings(s, p, owner);
break;
}
static void Drawer_InfluenceShapeBoxSettings(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner)
{
EditorGUILayout.BeginHorizontal();
EditorGUILayout.PropertyField(p.boxSize, CoreEditorUtils.GetContent("Box Size|The size of the box in which the reflections will be applied to objects. The value is not affected by the Transform of the Game Object."));
if (GUILayout.Button(toolbar_Contents[0], GUILayout.Width(28f), GUILayout.Height(EditorGUIUtility.singleLineHeight + 3)))
{
EditMode.ChangeEditMode(EditMode.SceneViewEditMode.ReflectionProbeBox, GetBoundsGetter(p)(), owner);
}
EditorGUILayout.EndHorizontal();
EditorGUI.BeginChangeCheck();
EditorGUILayout.BeginHorizontal();
EditorGUILayout.PropertyField(p.boxOffset, CoreEditorUtils.GetContent("Box Offset|The center of the box in which the reflections will be applied to objects. The value is relative to the position of the Game Object."));
if (GUILayout.Button(toolbar_Contents[3], GUILayout.Width(28f), GUILayout.Height(EditorGUIUtility.singleLineHeight + 3)))
{
EditMode.ChangeEditMode(EditMode.SceneViewEditMode.ReflectionProbeOrigin, GetBoundsGetter(p)(), owner);
}
EditorGUILayout.EndHorizontal();
if (EditorGUI.EndChangeCheck())
{
var center = p.boxOffset.vector3Value;
var size = p.boxSize.vector3Value;
if (HDReflectionProbeEditorUtility.ValidateAABB(p.target, ref center, ref size))
{
//clamp to contains object center instead of resizing
Vector3 projector = (center - p.boxOffset.vector3Value).normalized;
p.boxOffset.vector3Value = center + Mathf.Abs(Vector3.Dot((p.boxSize.vector3Value - size) * .5f, projector)) * projector;
}
}
}
static void Drawer_InfluenceShapeSphereSettings(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner)
{
EditorGUILayout.BeginHorizontal();
EditorGUILayout.PropertyField(p.influenceSphereRadius, CoreEditorUtils.GetContent("Radius"));
if (GUILayout.Button(toolbar_Contents[0], GUILayout.ExpandHeight(true), GUILayout.Width(28f), GUILayout.Height(EditorGUIUtility.singleLineHeight + 3)))
{
EditMode.ChangeEditMode(EditMode.SceneViewEditMode.ReflectionProbeBox, GetBoundsGetter(p)(), owner);
}
EditorGUILayout.EndHorizontal();
EditorGUILayout.BeginHorizontal();
EditorGUILayout.PropertyField(p.boxOffset, CoreEditorUtils.GetContent("Sphere Offset|The center of the sphere in which the reflections will be applied to objects. The value is relative to the position of the Game Object."));
if (GUILayout.Button(toolbar_Contents[3], GUILayout.ExpandHeight(true), GUILayout.Width(28f), GUILayout.Height(EditorGUIUtility.singleLineHeight + 3)))
{
EditMode.ChangeEditMode(EditMode.SceneViewEditMode.ReflectionProbeOrigin, GetBoundsGetter(p)(), owner);
}
EditorGUILayout.EndHorizontal();
}
static void Drawer_InfluenceAreas(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner)
{
if (s.IsSectionExpandedShape(ShapeType.Box).value)
{
Drawer_InfluenceBoxSettings(s, p, owner);
}
if (s.IsSectionExpandedShape(ShapeType.Sphere).value)
{
Drawer_InfluenceSphereSettings(s, p, owner);
}
}
static void Drawer_InfluenceSettings(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner)
{
EditorGUILayout.PropertyField(p.boxProjection, CoreEditorUtils.GetContent("Parallax Correction|Parallax Correction causes reflections to appear to change based on the object's position within the probe's box, while still using a single probe as the source of the reflection. This works well for reflections on objects that are moving through enclosed spaces such as corridors and rooms. Setting Parallax Correction to False and the cubemap reflection will be treated as coming from infinitely far away. Note that this feature can be globally disabled from Graphics Settings -> Tier Settings"));
}
static void Drawer_IntensityMultiplier(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner)

38
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDReflectionProbeUI.cs


using UnityEngine.Experimental.Rendering;
using UnityEngine.Experimental.Rendering.HDPipeline;
using UnityEngine.Rendering;
using UnityEngine.Experimental.Rendering;
namespace UnityEditor.Experimental.Rendering
{

public void ClearOperation(Operation op) { operations &= ~op; }
public void AddOperation(Operation op) { operations |= op; }
public BoxBoundsHandle boxInfluenceHandle = new BoxBoundsHandle();
public BoxBoundsHandle boxProjectionHandle = new BoxBoundsHandle();
public BoxBoundsHandle boxBlendHandle = new BoxBoundsHandle();
public BoxBoundsHandle boxBlendNormalHandle = new BoxBoundsHandle();
public Gizmo6FacesBox alternativeBoxInfluenceHandle;
public Gizmo6FacesBoxContained alternativeBoxBlendHandle;
public Gizmo6FacesBoxContained alternativeBoxBlendNormalHandle;
public SphereBoundsHandle sphereInfluenceHandle = new SphereBoundsHandle();
public SphereBoundsHandle sphereProjectionHandle = new SphereBoundsHandle();
public SphereBoundsHandle sphereBlendHandle = new SphereBoundsHandle();

public AnimBool isSectionExpandedInfluenceVolume { get { return m_AnimBools[0]; } }
public AnimBool isSectionExpandedSeparateProjection { get { return m_AnimBools[1]; } }
public AnimBool isSectionExpandedProxyVolume { get { return m_AnimBools[0]; } }
public AnimBool isSectionExpandedInfluenceVolume { get { return m_AnimBools[1]; } }
public AnimBool isSectionExpandedCaptureSettings { get { return m_AnimBools[2]; } }
public AnimBool isSectionExpandedAdditional { get { return m_AnimBools[3]; } }

public HDReflectionProbeUI()
: base(k_AnimBoolsCount)
{
isSectionExpandedProxyVolume.value = true;
alternativeBoxInfluenceHandle = new Gizmo6FacesBox(monochromeFace:true, monochromeSelectedFace:true);
alternativeBoxBlendHandle = new Gizmo6FacesBoxContained(alternativeBoxInfluenceHandle, monochromeFace:true, monochromeSelectedFace:true);
alternativeBoxBlendNormalHandle = new Gizmo6FacesBoxContained(alternativeBoxInfluenceHandle, monochromeFace:true, monochromeSelectedFace:true);
Color[] handleColors = new Color[]
{
HDReflectionProbeEditor.k_handlesColor[0][0],
HDReflectionProbeEditor.k_handlesColor[0][1],
HDReflectionProbeEditor.k_handlesColor[0][2],
HDReflectionProbeEditor.k_handlesColor[1][0],
HDReflectionProbeEditor.k_handlesColor[1][1],
HDReflectionProbeEditor.k_handlesColor[1][2]
};
alternativeBoxInfluenceHandle.handleColors = handleColors;
alternativeBoxBlendHandle.handleColors = handleColors;
alternativeBoxBlendNormalHandle.handleColors = handleColors;
alternativeBoxInfluenceHandle.faceColors = new Color[] { HDReflectionProbeEditor.k_GizmoThemeColorExtent };
alternativeBoxInfluenceHandle.faceColorsSelected = new Color[] { HDReflectionProbeEditor.k_GizmoThemeColorExtentFace };
alternativeBoxBlendHandle.faceColors = new Color[] { HDReflectionProbeEditor.k_GizmoThemeColorInfluenceBlend };
alternativeBoxBlendHandle.faceColorsSelected = new Color[] { HDReflectionProbeEditor.k_GizmoThemeColorInfluenceBlendFace };
alternativeBoxBlendNormalHandle.faceColors = new Color[] { HDReflectionProbeEditor.k_GizmoThemeColorInfluenceNormalBlend };
alternativeBoxBlendNormalHandle.faceColorsSelected = new Color[] { HDReflectionProbeEditor.k_GizmoThemeColorInfluenceNormalBlendFace };
}
public override void Update()

SetModeTarget(data.mode.hasMultipleDifferentValues ? -1 : data.mode.intValue);
SetShapeTarget(data.influenceShape.hasMultipleDifferentValues ? -1 : data.influenceShape.intValue);
isSectionExpandedSeparateProjection.value = data.useSeparateProjectionVolume.boolValue;
base.Update();
}

84
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/PlanarReflectionProbeUI.Drawers.cs


public static readonly CED.IDrawer Inspector;
public static readonly CED.IDrawer SectionProbeModeSettings;
public static readonly CED.IDrawer ProxyVolumeSettings = CED.FoldoutGroup(
"Proxy Volume",
(s, d, o) => s.isSectionExpendedProxyVolume,
FoldoutOption.Indent,
CED.Action(Drawer_SectionProxySettings)
);
public static readonly CED.IDrawer SectionFoldoutInfluenceSettings = CED.FoldoutGroup(
"Influence Settings",
(s, d, o) => s.isSectionExpandedInfluenceSettings,
public static readonly CED.IDrawer SectionFoldoutAdditionalSettings = CED.FoldoutGroup(
"Artistic Settings",
(s, d, o) => s.isSectionExpendedAdditionalSettings,
public static readonly CED.IDrawer SectionFoldoutProxySettings;
public static readonly CED.IDrawer SectionFoldoutCaptureSettings;
public static readonly CED.IDrawer SectionCaptureMirrorSettings = CED.Action(Drawer_SectionCaptureMirror);

CED.Action(Drawer_SectionCaptureSettings),
CED.FadeGroup(
(s, d, o, i) =>
{
switch (i)
{
default:
case 0: return s.isSectionExpandedCaptureMirrorSettings;
case 1: return s.isSectionExpandedCaptureStaticSettings;
}
},
{
switch (i)
{
default:
case 0: return s.isSectionExpandedCaptureMirrorSettings;
case 1: return s.isSectionExpandedCaptureStaticSettings;
}
},
FadeOption.None,
SectionCaptureMirrorSettings,
SectionCaptureStaticSettings)

);
Inspector = CED.Group(
//SectionProbeModeSettings,
CED.space,
CED.Action((s, d, o) => EditorGUILayout.LabelField(_.GetContent("Proxy Volume"), EditorStyles.boldLabel)),
CED.Action(Drawer_FieldProxyVolumeReference),
CED.space,
ProxyVolumeSettings,
CED.Select(
(s, d, o) => s.influenceVolume,
(s, d, o) => d.influenceVolume,

SectionFoldoutInfluenceSettings,
SectionFoldoutAdditionalSettings,
CED.Select(
(s, d, o) => s.frameSettings,
(s, d, o) => d.frameSettings,

GUI.enabled = true;
}
static void Drawer_SectionProxySettings(PlanarReflectionProbeUI s, SerializedPlanarReflectionProbe d, Editor o)
{
EditorGUILayout.PropertyField(d.proxyVolumeReference, _.GetContent("Reference"));
if (d.proxyVolumeReference.objectReferenceValue != null)
{
var proxy = (ReflectionProxyVolumeComponent)d.proxyVolumeReference.objectReferenceValue;
if ((int)proxy.proxyVolume.shapeType != d.influenceVolume.shapeType.enumValueIndex)
EditorGUILayout.HelpBox(
"Proxy volume and influence volume have different shape types, this is not supported.",
MessageType.Error,
true
);
}
else
{
EditorGUILayout.HelpBox(
"When no Proxy setted, Influence shape will be used as Proxy shape too.",
MessageType.Info,
true
);
}
}
static void Drawer_SectionInfluenceSettings(PlanarReflectionProbeUI s, SerializedPlanarReflectionProbe d, Editor o)
{
EditorGUILayout.PropertyField(d.weight, _.GetContent("Weight"));

GUI.enabled = true;
}
static void Drawer_FieldProxyVolumeReference(PlanarReflectionProbeUI s, SerializedPlanarReflectionProbe d, Editor o)
{
EditorGUILayout.PropertyField(d.proxyVolumeReference, _.GetContent("Reference"));
}
static readonly EditMode.SceneViewEditMode[] k_Toolbar_SceneViewEditModes =
{
EditBaseShape,

static readonly EditMode.SceneViewEditMode[] k_Toolbar_Static_SceneViewEditModes =
{
EditCenter
//EditCenter //offset have no meanings with planar
EditMirrorPosition,
//EditMirrorPosition, //offset have no meanings with planar
EditMirrorRotation
};
static GUIContent[] s_Toolbar_Contents = null;

{
get
{
return s_Toolbar_Static_Contents ?? (s_Toolbar_Static_Contents = new[]
return s_Toolbar_Static_Contents ?? (s_Toolbar_Static_Contents = new GUIContent[]
EditorGUIUtility.IconContent("MoveTool", "|Move the capture position.")
//EditorGUIUtility.IconContent("MoveTool", "|Move the capture position.") //offset have no meanings with planar
});
}
}

{
return s_Toolbar_Mirror_Contents ?? (s_Toolbar_Mirror_Contents = new[]
{
EditorGUIUtility.IconContent("MoveTool", "|Move the mirror plane."),
//EditorGUIUtility.IconContent("MoveTool", "|Move the mirror plane."), //offset have no meanings with planar
EditorGUIUtility.IconContent("RotateTool", "|Rotate the mirror plane.")
});
}

GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
}
static public void Drawer_ToolBarButton(int buttonIndex, Editor owner, params GUILayoutOption[] styles)
{
if (GUILayout.Button(toolbar_Contents[buttonIndex], styles))
{
EditMode.ChangeEditMode(k_Toolbar_SceneViewEditModes[buttonIndex], GetBoundsGetter(owner)(), owner);
}
}
static Func<Bounds> GetBoundsGetter(Editor o)

8
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/PlanarReflectionProbeUI.cs


{
partial class PlanarReflectionProbeUI : BaseUI<SerializedPlanarReflectionProbe>
{
const int k_AnimBoolFields = 4;
const int k_AnimBoolFields = 6;
static readonly int k_ReflectionProbeModeModeCount = Enum.GetValues(typeof(ReflectionProbeMode)).Length;
static readonly int k_AnimBoolTotal = k_AnimBoolFields + k_ReflectionProbeModeModeCount;

public AnimBool isSectionExpandedCaptureMirrorSettings { get { return m_AnimBools[k_ReflectionProbeModeModeCount + 2]; } }
public AnimBool isSectionExpandedCaptureStaticSettings { get { return m_AnimBools[k_ReflectionProbeModeModeCount + 3]; } }
public AnimBool isSectionExpendedProxyVolume { get { return m_AnimBools[k_ReflectionProbeModeModeCount + 4]; } }
public AnimBool isSectionExpendedAdditionalSettings { get { return m_AnimBools[k_ReflectionProbeModeModeCount + 5]; } }
public bool showCaptureHandles { get; set; }

isSectionExpandedInfluenceSettings.value = true;
isSectionExpandedCaptureSettings.value = true;
isSectionExpendedProxyVolume.value = true;
isSectionExpendedAdditionalSettings.value = false;
}
public AnimBool IsSectionExpandedReflectionProbeMode(ReflectionProbeMode mode)

43
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/SerializedHDReflectionProbe.cs


internal SerializedProperty weight;
internal SerializedProperty multiplier;
internal SerializedProperty editorAdvancedModeBlendDistancePositive;
internal SerializedProperty editorAdvancedModeBlendDistanceNegative;
internal SerializedProperty editorSimplifiedModeBlendDistance;
internal SerializedProperty editorAdvancedModeBlendNormalDistancePositive;
internal SerializedProperty editorAdvancedModeBlendNormalDistanceNegative;
internal SerializedProperty editorSimplifiedModeBlendNormalDistance;
internal SerializedProperty editorAdvancedModeEnabled;
internal SerializedProperty proxyVolumeComponent;
public SerializedHDReflectionProbe(SerializedObject so, SerializedObject addso)

blendNormalDistanceNegative = addso.Find((HDAdditionalReflectionData d) => d.blendNormalDistanceNegative);
boxSideFadePositive = addso.Find((HDAdditionalReflectionData d) => d.boxSideFadePositive);
boxSideFadeNegative = addso.Find((HDAdditionalReflectionData d) => d.boxSideFadeNegative);
editorAdvancedModeBlendDistancePositive = addso.FindProperty("editorAdvancedModeBlendDistancePositive");
editorAdvancedModeBlendDistanceNegative = addso.FindProperty("editorAdvancedModeBlendDistanceNegative");
editorSimplifiedModeBlendDistance = addso.FindProperty("editorSimplifiedModeBlendDistance");
editorAdvancedModeBlendNormalDistancePositive = addso.FindProperty("editorAdvancedModeBlendNormalDistancePositive");
editorAdvancedModeBlendNormalDistanceNegative = addso.FindProperty("editorAdvancedModeBlendNormalDistanceNegative");
editorSimplifiedModeBlendNormalDistance = addso.FindProperty("editorSimplifiedModeBlendNormalDistance");
editorAdvancedModeEnabled = addso.FindProperty("editorAdvancedModeEnabled");
//handle data migration from before editor value were saved
if(editorAdvancedModeBlendDistancePositive.vector3Value == Vector3.zero
&& editorAdvancedModeBlendDistanceNegative.vector3Value == Vector3.zero
&& editorSimplifiedModeBlendDistance.floatValue == 0f
&& editorAdvancedModeBlendNormalDistancePositive.vector3Value == Vector3.zero
&& editorAdvancedModeBlendNormalDistanceNegative.vector3Value == Vector3.zero
&& editorSimplifiedModeBlendNormalDistance.floatValue == 0f)
{
Vector3 positive = blendDistancePositive.vector3Value;
Vector3 negative = blendDistanceNegative.vector3Value;
//exact advanced
editorAdvancedModeBlendDistancePositive.vector3Value = positive;
editorAdvancedModeBlendDistanceNegative.vector3Value = negative;
//aproximated simplified
editorSimplifiedModeBlendDistance.floatValue = Mathf.Max(positive.x, positive.y, positive.z, negative.x, negative.y, negative.z);
positive = blendNormalDistancePositive.vector3Value;
negative = blendNormalDistanceNegative.vector3Value;
//exact advanced
editorAdvancedModeBlendNormalDistancePositive.vector3Value = positive;
editorAdvancedModeBlendNormalDistanceNegative.vector3Value = negative;
//aproximated simplified
editorSimplifiedModeBlendNormalDistance.floatValue = Mathf.Max(positive.x, positive.y, positive.z, negative.x, negative.y, negative.z);
//display old data
editorAdvancedModeEnabled.boolValue = true;
}
proxyVolumeComponent = addso.Find((HDAdditionalReflectionData d) => d.proxyVolumeComponent);
}

127
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/Volume/InfluenceVolumeUI.Drawers.cs


partial class InfluenceVolumeUI
{
public static readonly CED.IDrawer SectionShape;
public static readonly CED.IDrawer FieldShape = CED.Action(Drawer_FieldShapeType);
public static readonly CED.IDrawer SectionShapeBox = CED.Action(Drawer_SectionShapeBox);
public static readonly CED.IDrawer SectionShapeSphere = CED.Action(Drawer_SectionShapeSphere);

SectionShape = CED.Group(
CED.Action(Drawer_FieldShapeType),
CED.FadeGroup(
(s, d, o, i) => s.IsSectionExpanded_Shape((ShapeType)i),
FadeOption.Indent,
SectionShapeBox,
SectionShapeSphere
)
);
CED.Action(Drawer_InfluenceAdvancedSwitch),
CED.space,
CED.Action(Drawer_FieldShapeType),
CED.FadeGroup(
(s, d, o, i) => s.IsSectionExpanded_Shape((ShapeType)i),

EditorGUILayout.PropertyField(d.shapeType, _.GetContent("Shape Type"));
}
static void Drawer_InfluenceAdvancedSwitch(InfluenceVolumeUI s, SerializedInfluenceVolume d, Editor owner)
{
using (new EditorGUILayout.HorizontalScope())
{
GUILayout.FlexibleSpace();
bool advanced = d.editorAdvancedModeEnabled.boolValue;
advanced = !GUILayout.Toggle(!advanced, CoreEditorUtils.GetContent("Normal|Normal parameters mode (only change for box shape)."), EditorStyles.miniButtonLeft, GUILayout.Width(60f), GUILayout.ExpandWidth(false));
advanced = GUILayout.Toggle(advanced, CoreEditorUtils.GetContent("Advanced|Advanced parameters mode (only change for box shape)."), EditorStyles.miniButtonRight, GUILayout.Width(60f), GUILayout.ExpandWidth(false));
s.boxInfluenceHandle.allHandleControledByOne = s.boxInfluenceNormalHandle.allHandleControledByOne = !advanced;
if (d.editorAdvancedModeEnabled.boolValue ^ advanced)
{
d.editorAdvancedModeEnabled.boolValue = advanced;
if (advanced)
{
d.boxInfluencePositiveFade.vector3Value = d.editorAdvancedModeBlendDistancePositive.vector3Value;
d.boxInfluenceNegativeFade.vector3Value = d.editorAdvancedModeBlendDistanceNegative.vector3Value;
d.boxInfluenceNormalPositiveFade.vector3Value = d.editorAdvancedModeBlendNormalDistancePositive.vector3Value;
d.boxInfluenceNormalNegativeFade.vector3Value = d.editorAdvancedModeBlendNormalDistanceNegative.vector3Value;
}
else
{
d.boxInfluenceNegativeFade.vector3Value = d.boxInfluencePositiveFade.vector3Value = Vector3.one * d.editorSimplifiedModeBlendDistance.floatValue;
d.boxInfluenceNormalNegativeFade.vector3Value = d.boxInfluenceNormalPositiveFade.vector3Value = Vector3.one * d.editorSimplifiedModeBlendNormalDistance.floatValue;
}
d.Apply();
}
}
}
bool advanced = d.editorAdvancedModeEnabled.boolValue;
EditorGUILayout.BeginHorizontal();
EditorGUILayout.PropertyField(d.boxBaseOffset, _.GetContent("Box Offset"));
PlanarReflectionProbeUI.Drawer_ToolBarButton(0, o, GUILayout.Width(28f), GUILayout.MinHeight(22f));
EditorGUILayout.EndHorizontal();
EditorGUILayout.Space();
//offset have no meaning for planar reflexion probe
//EditorGUILayout.PropertyField(d.boxBaseOffset, _.GetContent("Box Offset"));
_.DrawVector6Slider(
_.GetContent("Influence Fade"),
d.boxInfluencePositiveFade, d.boxInfluenceNegativeFade,
minFadeDistance, maxFadeDistance);
EditorGUILayout.BeginHorizontal();
Drawer_AdvancedBlendDistance(
d,
false,
maxFadeDistance,
CoreEditorUtils.GetContent("Blend Distance|Area around the probe where it is blended with other probes. Only used in deferred probes.")
);
PlanarReflectionProbeUI.Drawer_ToolBarButton(1, o, GUILayout.ExpandHeight(true), GUILayout.Width(28f), GUILayout.MinHeight(22f), GUILayout.MaxHeight((advanced ? 3 : 1) * (EditorGUIUtility.singleLineHeight + 3)));
EditorGUILayout.EndHorizontal();
if (advanced)
{
CoreEditorUtils.DrawVector6(
CoreEditorUtils.GetContent("Face fade|Fade faces of the cubemap."),
d.boxPositiveFaceFade, d.boxNegativeFaceFade, Vector3.zero, Vector3.one, HDReflectionProbeEditor.k_handlesColor);
}
}
EditorGUILayout.Space();
static void Drawer_AdvancedBlendDistance(SerializedInfluenceVolume d, bool isNormal, Vector3 maxBlendDistance, GUIContent content)
{
SerializedProperty blendDistancePositive = isNormal ? d.boxInfluenceNormalPositiveFade : d.boxInfluencePositiveFade;
SerializedProperty blendDistanceNegative = isNormal ? d.boxInfluenceNormalNegativeFade : d.boxInfluenceNegativeFade;
SerializedProperty editorAdvancedModeBlendDistancePositive = isNormal ? d.editorAdvancedModeBlendNormalDistancePositive : d.editorAdvancedModeBlendDistancePositive;
SerializedProperty editorAdvancedModeBlendDistanceNegative = isNormal ? d.editorAdvancedModeBlendNormalDistanceNegative : d.editorAdvancedModeBlendDistanceNegative;
SerializedProperty editorSimplifiedModeBlendDistance = isNormal ? d.editorSimplifiedModeBlendNormalDistance : d.editorSimplifiedModeBlendDistance;
Vector3 bdp = blendDistancePositive.vector3Value;
Vector3 bdn = blendDistanceNegative.vector3Value;
_.DrawVector6Slider(
_.GetContent("Influence Normal Fade"),
d.boxInfluenceNormalPositiveFade, d.boxInfluenceNormalNegativeFade,
minFadeDistance, maxFadeDistance);
EditorGUILayout.BeginVertical();
EditorGUILayout.Space();
if (d.editorAdvancedModeEnabled.boolValue)
{
EditorGUI.BeginChangeCheck();
blendDistancePositive.vector3Value = editorAdvancedModeBlendDistancePositive.vector3Value;
blendDistanceNegative.vector3Value = editorAdvancedModeBlendDistanceNegative.vector3Value;
CoreEditorUtils.DrawVector6(
content,
blendDistancePositive, blendDistanceNegative, Vector3.zero, maxBlendDistance, HDReflectionProbeEditor.k_handlesColor);
if(EditorGUI.EndChangeCheck())
{
editorAdvancedModeBlendDistancePositive.vector3Value = blendDistancePositive.vector3Value;
editorAdvancedModeBlendDistanceNegative.vector3Value = blendDistanceNegative.vector3Value;
}
}
else
{
float distance = editorSimplifiedModeBlendDistance.floatValue;
EditorGUI.BeginChangeCheck();
distance = EditorGUILayout.FloatField(content, distance);
if (EditorGUI.EndChangeCheck())
{
Vector3 decal = Vector3.one * distance;
bdp.x = Mathf.Clamp(decal.x, 0f, maxBlendDistance.x);
bdp.y = Mathf.Clamp(decal.y, 0f, maxBlendDistance.y);
bdp.z = Mathf.Clamp(decal.z, 0f, maxBlendDistance.z);
bdn.x = Mathf.Clamp(decal.x, 0f, maxBlendDistance.x);
bdn.y = Mathf.Clamp(decal.y, 0f, maxBlendDistance.y);
bdn.z = Mathf.Clamp(decal.z, 0f, maxBlendDistance.z);
blendDistancePositive.vector3Value = bdp;
blendDistanceNegative.vector3Value = bdn;
editorSimplifiedModeBlendDistance.floatValue = distance;
}
}
_.DrawVector6Slider(
_.GetContent("Influence Face Fade"),
d.boxPositiveFaceFade, d.boxNegativeFaceFade,
Vector3.zero, Vector3.one);
GUILayout.EndVertical();
}
static void Drawer_SectionShapeSphere(InfluenceVolumeUI s, SerializedInfluenceVolume d, Editor o)

24
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/Volume/InfluenceVolumeUI.Gizmos.cs


using System;
using UnityEngine;
using UnityEngine.Experimental.Rendering.HDPipeline;
using UnityEngine.Experimental.Rendering;
namespace UnityEditor.Experimental.Rendering.HDPipeline
{

d.boxInfluenceOffset, d.boxInfluenceSizeOffset,
d.sphereInfluenceRadiusOffset,
(editedHandle & HandleType.Influence) != 0,
k_GizmoThemeColorInfluence);
k_GizmoThemeColorInfluence,
false);
if ((showedHandle & HandleType.InfluenceNormal) != 0)
DrawGizmos_FadeHandle(

(editedHandle & HandleType.InfluenceNormal) != 0,
k_GizmoThemeColorInfluenceNormal);
k_GizmoThemeColorInfluenceNormal,
true);
}
static void DrawGizmos_BaseHandle(

{
case ShapeType.Box:
{
if (isSolid)
Gizmos.DrawCube(d.boxBaseOffset, d.boxBaseSize);
else
Gizmos.DrawWireCube(d.boxBaseOffset, d.boxBaseSize);
s.boxBaseHandle.center = d.boxBaseOffset;
s.boxBaseHandle.size = d.boxBaseSize;
s.boxBaseHandle.DrawHull(isSolid);
break;
}
case ShapeType.Sphere:

InfluenceVolumeUI s, InfluenceVolume d, Matrix4x4 matrix,
Vector3 boxOffset, Vector3 boxSizeOffset,
float sphereOffset,
bool isSolid, Color color)
bool isSolid, Color color, bool isNormal)
{
var mat = Gizmos.matrix;
var c = Gizmos.color;

{
case ShapeType.Box:
{
if (isSolid)
Gizmos.DrawCube(d.boxBaseOffset + boxOffset, d.boxBaseSize + boxSizeOffset);
else
Gizmos.DrawWireCube(d.boxBaseOffset + boxOffset, d.boxBaseSize + boxSizeOffset);
Gizmo6FacesBox refBox = isNormal ? s.boxInfluenceNormalHandle : s.boxInfluenceHandle;
refBox.center = d.boxBaseOffset + boxOffset;
refBox.size = d.boxBaseSize + boxSizeOffset;
refBox.DrawHull(isSolid);
break;
}
case ShapeType.Sphere:

171
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/Volume/InfluenceVolumeUI.Handles.cs


using UnityEngine;
using UnityEngine.Experimental.Rendering.HDPipeline;
using Object = UnityEngine.Object;
using UnityEngine.Experimental.Rendering;
namespace UnityEditor.Experimental.Rendering.HDPipeline
{

switch (d.shapeType)
{
case ShapeType.Box:
{
var center = d.boxBaseOffset;
var size = d.boxBaseSize;
DrawBoxHandle(
s, d, o, sourceAsset,
s1 => s1.boxBaseHandle,
ref center,
ref size);
d.boxBaseOffset = center;
d.boxBaseSize = size;
break;
}
{
var center = d.boxBaseOffset;
var size = d.boxBaseSize;
DrawBoxHandle(
s, d, o, sourceAsset,
s1 => s1.boxBaseHandle,
ref center,
ref size);
d.boxBaseOffset = center;
d.boxBaseSize = size;
break;
}
{
var center = d.sphereBaseOffset;
var radius = d.sphereBaseRadius;
DrawSphereHandle(
s, d, o, sourceAsset,
s1 => s1.sphereBaseHandle,
ref center,
ref radius);
d.sphereBaseOffset = center;
d.sphereBaseRadius = radius;
break;
}
{
var center = d.sphereBaseOffset;
var radius = d.sphereBaseRadius;
DrawSphereHandle(
s, d, o, sourceAsset,
s1 => s1.sphereBaseHandle,
ref center,
ref radius);
d.sphereBaseOffset = center;
d.sphereBaseRadius = radius;
break;
}
}
Handles.matrix = mat;
Handles.color = c;

switch (d.shapeType)
{
case ShapeType.Box:
{
var positive = d.boxInfluencePositiveFade;
var negative = d.boxInfluenceNegativeFade;
DrawBoxFadeHandle(
s, d, o, sourceAsset,
s1 => s1.boxInfluenceHandle,
d.boxBaseOffset, d.boxBaseSize,
ref positive,
ref negative);
d.boxInfluencePositiveFade = positive;
d.boxInfluenceNegativeFade = negative;
break;
}
{
var positive = d.boxInfluencePositiveFade;
var negative = d.boxInfluenceNegativeFade;
DrawBoxFadeHandle(
s, d, o, sourceAsset,
s1 => s1.boxInfluenceHandle,
d.boxBaseOffset, d.boxBaseSize,
ref positive,
ref negative);
s.data.boxInfluencePositiveFade.vector3Value = positive;
s.data.boxInfluenceNegativeFade.vector3Value = negative;
//save advanced/simplified saved data
if (s.data.editorAdvancedModeEnabled.boolValue)
{
s.data.editorAdvancedModeBlendDistancePositive.vector3Value = positive;
s.data.editorAdvancedModeBlendDistanceNegative.vector3Value = negative;
}
else
{
s.data.editorSimplifiedModeBlendDistance.floatValue = positive.x;
}
s.data.Apply();
break;
}
{
var fade = d.sphereInfluenceFade;
DrawSphereFadeHandle(
s, d, o, sourceAsset,
s1 => s1.sphereInfluenceHandle,
d.sphereBaseOffset, d.sphereBaseRadius,
ref fade);
d.sphereInfluenceFade = fade;
break;
}
{
var fade = d.sphereInfluenceFade;
DrawSphereFadeHandle(
s, d, o, sourceAsset,
s1 => s1.sphereInfluenceHandle,
d.sphereBaseOffset, d.sphereBaseRadius,
ref fade);
d.sphereInfluenceFade = fade;
break;
}
}
Handles.matrix = mat;
Handles.color = c;

switch (d.shapeType)
{
case ShapeType.Box:
{
var positive = d.boxInfluenceNormalPositiveFade;
var negative = d.boxInfluenceNormalNegativeFade;
DrawBoxFadeHandle(
s, d, o, sourceAsset,
s1 => s1.boxInfluenceNormalHandle,
d.boxBaseOffset, d.boxBaseSize,
ref positive,
ref negative);
d.boxInfluenceNormalPositiveFade = positive;
d.boxInfluenceNormalNegativeFade = negative;
break;
}
{
Vector3 positive = d.boxInfluenceNormalPositiveFade;
Vector3 negative = d.boxInfluenceNormalNegativeFade;
DrawBoxFadeHandle(
s, d, o, sourceAsset,
s1 => s1.boxInfluenceNormalHandle,
d.boxBaseOffset, d.boxBaseSize,
ref positive,
ref negative);
s.data.boxInfluenceNormalPositiveFade.vector3Value = positive;
s.data.boxInfluenceNormalNegativeFade.vector3Value = negative;
//save advanced/simplified saved data
if (s.data.editorAdvancedModeEnabled.boolValue)
{
s.data.editorAdvancedModeBlendNormalDistancePositive.vector3Value = positive;
s.data.editorAdvancedModeBlendNormalDistanceNegative.vector3Value = negative;
}
else
{
s.data.editorSimplifiedModeBlendNormalDistance.floatValue = positive.x;
}
s.data.Apply();
break;
}
{
var fade = d.sphereInfluenceNormalFade;
DrawSphereFadeHandle(
s, d, o, sourceAsset,
s1 => s1.sphereInfluenceNormalHandle,
d.sphereBaseOffset, d.sphereBaseRadius,
ref fade);
d.sphereInfluenceNormalFade = fade;
break;
}
{
var fade = d.sphereInfluenceNormalFade;
DrawSphereFadeHandle(
s, d, o, sourceAsset,
s1 => s1.sphereInfluenceNormalHandle,
d.sphereBaseOffset, d.sphereBaseRadius,
ref fade);
d.sphereInfluenceNormalFade = fade;
break;
}
}
Handles.matrix = mat;
Handles.color = c;

InfluenceVolumeUI s, InfluenceVolume d, Editor o, Object sourceAsset,
Func<InfluenceVolumeUI, BoxBoundsHandle> boundsGetter,
Func<InfluenceVolumeUI, Gizmo6FacesBox> boundsGetter,
ref Vector3 center, ref Vector3 size)
{
var b = boundsGetter(s);

static void DrawBoxFadeHandle(
InfluenceVolumeUI s, InfluenceVolume d, Editor o, Object sourceAsset,
Func<InfluenceVolumeUI, BoxBoundsHandle> boundsGetter,
Func<InfluenceVolumeUI, Gizmo6FacesBox> boundsGetter,
Vector3 baseOffset, Vector3 baseSize,
ref Vector3 positive, ref Vector3 negative)
{

b.size = baseSize - positive - negative;
b.allHandleControledByOne = !s.data.editorAdvancedModeEnabled.boolValue;
EditorGUI.BeginChangeCheck();
b.DrawHandle();

55
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/Volume/InfluenceVolumeUI.cs


using UnityEditor.IMGUI.Controls;
using UnityEngine;
using UnityEngine.Experimental.Rendering.HDPipeline;
using UnityEngine.Experimental.Rendering;
internal static Color k_GizmoThemeColorBase = new Color(255f / 255f, 229f / 255f, 148f / 255f, 80f / 255f);
internal static Color k_GizmoThemeColorBaseFace = new Color(255f / 255f, 229f / 255f, 148f / 255f, 45f / 255f);
internal static Color k_GizmoThemeColorInfluence = new Color(83f / 255f, 255f / 255f, 95f / 255f, 75f / 255f);
internal static Color k_GizmoThemeColorInfluenceFace = new Color(83f / 255f, 255f / 255f, 95f / 255f, 17f / 255f);
internal static Color k_GizmoThemeColorInfluenceNormal = new Color(0f / 255f, 229f / 255f, 255f / 255f, 80f / 255f);
internal static Color k_GizmoThemeColorInfluenceNormalFace = new Color(0f / 255f, 229f / 255f, 255f / 255f, 36f / 255f);
internal static Color k_GizmoThemeColorProjection = new Color(0x00 / 255f, 0xE5 / 255f, 0xFF / 255f, 0x20 / 255f);
internal static Color k_GizmoThemeColorProjectionFace = new Color(0x00 / 255f, 0xE5 / 255f, 0xFF / 255f, 0x20 / 255f);
internal static Color k_GizmoThemeColorDisabled = new Color(0x99 / 255f, 0x89 / 255f, 0x59 / 255f, 0x10 / 255f);
internal static Color k_GizmoThemeColorDisabledFace = new Color(0x99 / 255f, 0x89 / 255f, 0x59 / 255f, 0x10 / 255f);
const int k_AnimBoolFields = 2;
internal static readonly Color k_GizmoThemeColorBase = new Color(255f / 255f, 229f / 255f, 148f / 255f, 80f / 255f);
internal static readonly Color k_GizmoThemeColorBaseFace = new Color(255f / 255f, 229f / 255f, 148f / 255f, 45f / 255f);
internal static readonly Color k_GizmoThemeColorInfluence = new Color(83f / 255f, 255f / 255f, 95f / 255f, 75f / 255f);
internal static readonly Color k_GizmoThemeColorInfluenceFace = new Color(83f / 255f, 255f / 255f, 95f / 255f, 17f / 255f);
internal static readonly Color k_GizmoThemeColorInfluenceNormal = new Color(0f / 255f, 229f / 255f, 255f / 255f, 80f / 255f);
internal static readonly Color k_GizmoThemeColorInfluenceNormalFace = new Color(0f / 255f, 229f / 255f, 255f / 255f, 36f / 255f);
internal static readonly Color k_GizmoThemeColorProjection = new Color(0x00 / 255f, 0xE5 / 255f, 0xFF / 255f, 0x20 / 255f);
internal static readonly Color k_GizmoThemeColorProjectionFace = new Color(0x00 / 255f, 0xE5 / 255f, 0xFF / 255f, 0x20 / 255f);
internal static readonly Color k_GizmoThemeColorDisabled = new Color(0x99 / 255f, 0x89 / 255f, 0x59 / 255f, 0x10 / 255f);
internal static readonly Color k_GizmoThemeColorDisabledFace = new Color(0x99 / 255f, 0x89 / 255f, 0x59 / 255f, 0x10 / 255f);
public BoxBoundsHandle boxBaseHandle = new BoxBoundsHandle();
public BoxBoundsHandle boxInfluenceHandle = new BoxBoundsHandle();
public BoxBoundsHandle boxInfluenceNormalHandle = new BoxBoundsHandle();
public Gizmo6FacesBox boxBaseHandle;
public Gizmo6FacesBoxContained boxInfluenceHandle;
public Gizmo6FacesBoxContained boxInfluenceNormalHandle;
public SphereBoundsHandle sphereBaseHandle = new SphereBoundsHandle();
public SphereBoundsHandle sphereInfluenceHandle = new SphereBoundsHandle();

public bool showInfluenceHandles { get; set; }
public InfluenceVolumeUI()
: base(k_ShapeCount + 1)
: base(k_ShapeCount + k_AnimBoolFields)
isSectionExpandedShape.value = true;
boxBaseHandle = new Gizmo6FacesBox(monochromeFace:true, monochromeSelectedFace:true);
boxInfluenceHandle = new Gizmo6FacesBoxContained(boxBaseHandle, monochromeFace:true, monochromeSelectedFace:true);
boxInfluenceNormalHandle = new Gizmo6FacesBoxContained(boxBaseHandle, monochromeFace:true, monochromeSelectedFace:true);
Color[] handleColors = new Color[]
{
HDReflectionProbeEditor.k_handlesColor[0][0],
HDReflectionProbeEditor.k_handlesColor[0][1],
HDReflectionProbeEditor.k_handlesColor[0][2],
HDReflectionProbeEditor.k_handlesColor[1][0],
HDReflectionProbeEditor.k_handlesColor[1][1],
HDReflectionProbeEditor.k_handlesColor[1][2]
};
boxBaseHandle.handleColors = handleColors;
boxInfluenceHandle.handleColors = handleColors;
boxInfluenceNormalHandle.handleColors = handleColors;
boxBaseHandle.faceColors = new Color[] { HDReflectionProbeEditor.k_GizmoThemeColorExtent };
boxBaseHandle.faceColorsSelected = new Color[] { HDReflectionProbeEditor.k_GizmoThemeColorExtentFace };
boxInfluenceHandle.faceColors = new Color[] { HDReflectionProbeEditor.k_GizmoThemeColorInfluenceBlend };
boxInfluenceHandle.faceColorsSelected = new Color[] { HDReflectionProbeEditor.k_GizmoThemeColorInfluenceBlendFace };
boxInfluenceNormalHandle.faceColors = new Color[] { HDReflectionProbeEditor.k_GizmoThemeColorInfluenceNormalBlend };
boxInfluenceNormalHandle.faceColorsSelected = new Color[] { HDReflectionProbeEditor.k_GizmoThemeColorInfluenceNormalBlendFace };
}
public override void Update()

49
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/Volume/SerializedInfluenceVolume.cs


using UnityEngine;
using UnityEngine.Experimental.Rendering.HDPipeline;
namespace UnityEditor.Experimental.Rendering.HDPipeline

public SerializedProperty sphereInfluenceFade;
public SerializedProperty sphereInfluenceNormalFade;
internal SerializedProperty editorAdvancedModeBlendDistancePositive;
internal SerializedProperty editorAdvancedModeBlendDistanceNegative;
internal SerializedProperty editorSimplifiedModeBlendDistance;
internal SerializedProperty editorAdvancedModeBlendNormalDistancePositive;
internal SerializedProperty editorAdvancedModeBlendNormalDistanceNegative;
internal SerializedProperty editorSimplifiedModeBlendNormalDistance;
internal SerializedProperty editorAdvancedModeEnabled;
public SerializedInfluenceVolume(SerializedProperty root)
{
this.root = root;

sphereBaseOffset = root.Find((InfluenceVolume i) => i.sphereBaseOffset);
sphereInfluenceFade = root.Find((InfluenceVolume i) => i.sphereInfluenceFade);
sphereInfluenceNormalFade = root.Find((InfluenceVolume i) => i.sphereInfluenceNormalFade);
editorAdvancedModeBlendDistancePositive = root.FindPropertyRelative("editorAdvancedModeBlendDistancePositive");
editorAdvancedModeBlendDistanceNegative = root.FindPropertyRelative("editorAdvancedModeBlendDistanceNegative");
editorSimplifiedModeBlendDistance = root.FindPropertyRelative("editorSimplifiedModeBlendDistance");
editorAdvancedModeBlendNormalDistancePositive = root.FindPropertyRelative("editorAdvancedModeBlendNormalDistancePositive");
editorAdvancedModeBlendNormalDistanceNegative = root.FindPropertyRelative("editorAdvancedModeBlendNormalDistanceNegative");
editorSimplifiedModeBlendNormalDistance = root.FindPropertyRelative("editorSimplifiedModeBlendNormalDistance");
editorAdvancedModeEnabled = root.FindPropertyRelative("editorAdvancedModeEnabled");
//handle data migration from before editor value were saved
if(editorAdvancedModeBlendDistancePositive.vector3Value == Vector3.zero
&& editorAdvancedModeBlendDistanceNegative.vector3Value == Vector3.zero
&& editorSimplifiedModeBlendDistance.floatValue == 0f
&& editorAdvancedModeBlendNormalDistancePositive.vector3Value == Vector3.zero
&& editorAdvancedModeBlendNormalDistanceNegative.vector3Value == Vector3.zero
&& editorSimplifiedModeBlendNormalDistance.floatValue == 0f)
{
Vector3 positive = boxInfluencePositiveFade.vector3Value;
Vector3 negative = boxInfluenceNegativeFade.vector3Value;
//exact advanced
editorAdvancedModeBlendDistancePositive.vector3Value = positive;
editorAdvancedModeBlendDistanceNegative.vector3Value = negative;
//aproximated simplified
editorSimplifiedModeBlendDistance.floatValue = Mathf.Max(positive.x, positive.y, positive.z, negative.x, negative.y, negative.z);
positive = boxInfluenceNormalPositiveFade.vector3Value;
negative = boxInfluenceNormalNegativeFade.vector3Value;
//exact advanced
editorAdvancedModeBlendNormalDistancePositive.vector3Value = positive;
editorAdvancedModeBlendNormalDistanceNegative.vector3Value = negative;
//aproximated simplified
editorSimplifiedModeBlendNormalDistance.floatValue = Mathf.Max(positive.x, positive.y, positive.z, negative.x, negative.y, negative.z);
//display old data
editorAdvancedModeEnabled.boolValue = true;
}
}
public void Apply()
{
root.serializedObject.ApplyModifiedProperties();
}
}
}

12
com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/HDAdditionalReflectionData.cs


public Vector3 boxSideFadePositive = Vector3.one;
public Vector3 boxSideFadeNegative = Vector3.one;
#if UNITY_EDITOR
//editor value that need to be saved for easy passing from simplified to advanced and vice et versa
// /!\ must not be used outside editor code
[SerializeField] private Vector3 editorAdvancedModeBlendDistancePositive;
[SerializeField] private Vector3 editorAdvancedModeBlendDistanceNegative;
[SerializeField] private float editorSimplifiedModeBlendDistance;
[SerializeField] private Vector3 editorAdvancedModeBlendNormalDistancePositive;
[SerializeField] private Vector3 editorAdvancedModeBlendNormalDistanceNegative;
[SerializeField] private float editorSimplifiedModeBlendNormalDistance;
[SerializeField] private bool editorAdvancedModeEnabled;
#endif
public ReflectionProxyVolumeComponent proxyVolumeComponent;
public Vector3 boxBlendCenterOffset { get { return (blendDistanceNegative - blendDistancePositive) * 0.5f; } }

12
com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/Volumes/InfluenceVolume.cs


[SerializeField]
Vector3 m_BoxNegativeFaceFade = Vector3.one;
#if UNITY_EDITOR
//editor value that need to be saved for easy passing from simplified to advanced and vice et versa
// /!\ must not be used outside editor code
[SerializeField] private Vector3 editorAdvancedModeBlendDistancePositive;
[SerializeField] private Vector3 editorAdvancedModeBlendDistanceNegative;
[SerializeField] private float editorSimplifiedModeBlendDistance;
[SerializeField] private Vector3 editorAdvancedModeBlendNormalDistancePositive;
[SerializeField] private Vector3 editorAdvancedModeBlendNormalDistanceNegative;
[SerializeField] private float editorSimplifiedModeBlendNormalDistance;
[SerializeField] private bool editorAdvancedModeEnabled;
#endif
// Sphere
[SerializeField]
float m_SphereBaseRadius = 1;

8
com.unity.render-pipelines.core/CoreRP/Tool.meta


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

11
com.unity.render-pipelines.core/CoreRP/Tool/Gizmo6FacesBox.cs.meta


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

422
com.unity.render-pipelines.core/CoreRP/Tool/Gizmo6FacesBox.cs


using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using System.Reflection;
namespace UnityEngine.Experimental.Rendering
{
public class Gizmo6FacesBox
{
const float k_HandleSizeCoef = 0.05f;
protected enum NamedFace { Right, Top, Front, Left, Bottom, Back, None }
protected enum Element { Face, SelectedFace, Handle }
Mesh m_face = null;
Mesh face
{
get
{
if (m_face == null)
{
m_face = new Mesh();
m_face.vertices = new Vector3[] {
new Vector3(-.5f,-.5f,0f),
new Vector3(+.5f,-.5f,0f),
new Vector3(+.5f,+.5f,0f),
new Vector3(-.5f,+.5f,0f)
};
m_face.triangles = new int[] {
0, 1, 2,
2, 3, 0
};
m_face.RecalculateNormals();
}
return m_face;
}
}
Color[] m_faceColorsSelected;
public Color[] faceColorsSelected
{
get
{
return m_faceColorsSelected ?? (m_faceColorsSelected = new Color[]
{
new Color(1f, 0f, 0f, .15f),
new Color(0f, 1f, 0f, .15f),
new Color(0f, 0f, 1f, .15f),
new Color(1f, 0f, 0f, .15f),
new Color(0f, 1f, 0f, .15f),
new Color(0f, 0f, 1f, .15f)
});
return m_faceColorsSelected ?? (m_faceColorsSelected = monochromeSelectedFace
? new Color[]
{
new Color(1f, 1f, 1f, .15f)
}
: new Color[]
{
new Color(1f, 0f, 0f, .15f),
new Color(0f, 1f, 0f, .15f),
new Color(0f, 0f, 1f, .15f),
new Color(1f, 0f, 0f, .15f),
new Color(0f, 1f, 0f, .15f),
new Color(0f, 0f, 1f, .15f)
});
}
set
{
if (value == null)
{
throw new ArgumentNullException("FaceColor cannot be set to null.");
}
if (value.Length != (monochromeSelectedFace ? 1 : 6))
{
throw new ArgumentException("FaceColor must have 6 entries: X Y Z -X -Y -Z or only one in monochrome mode");
}
m_faceColorsSelected = value;
}
}
Color[] m_faceColors;
public Color[] faceColors
{
get
{
return m_faceColors ?? (m_faceColors = monochromeFace
? new Color[]
{
new Color(.5f, .5f, .5f, .15f)
}
: new Color[]
{
new Color(.5f, 0f, 0f, .15f),
new Color(0f, .5f, 0f, .15f),
new Color(0f, 0f, .5f, .15f),
new Color(.5f, 0f, 0f, .15f),
new Color(0f, .5f, 0f, .15f),
new Color(0f, 0f, .5f, .15f)
});
}
set
{
if (value == null)
{
throw new ArgumentNullException("FaceColor cannot be set to null.");
}
if (value.Length != (monochromeFace ? 1 : 6))
{
throw new ArgumentException("FaceColor must have 6 entries: X Y Z -X -Y -Z or only one in monochrome mode");
}
m_faceColors = value;
}
}
Color[] m_handleColors;
public Color[] handleColors
{
get
{
return m_handleColors ?? (m_handleColors = monochromeHandle
? new Color[]
{
new Color(1f, 0f, 0f, 1f)
}
: new Color[]
{
new Color(1f, 0f, 0f, 1f),
new Color(0f, 1f, 0f, 1f),
new Color(0f, 0f, 1f, 1f),
new Color(1f, 0f, 0f, 1f),
new Color(0f, 1f, 0f, 1f),
new Color(0f, 0f, 1f, 1f)
});
}
set
{
if (value == null)
{
throw new ArgumentNullException("HandleColor cannot be set to null.");
}
if (value.Length != (monochromeHandle ? 1 : 6))
{
throw new ArgumentException("HandleColor must have 6 entries: X Y Z -X -Y -Z or only one in monochrome mode");
}
m_handleColors = value;
}
}
public readonly bool monochromeHandle;
public readonly bool monochromeFace;
public readonly bool monochromeSelectedFace;
public bool allHandleControledByOne = false;
private int[] m_ControlIDs = new int[6] { 0, 0, 0, 0, 0, 0 };
public Vector3 center { get; set; }
public Vector3 size { get; set; }
public Gizmo6FacesBox(bool monochromeHandle = false, bool monochromeFace = false, bool monochromeSelectedFace = false)
{
this.monochromeHandle = monochromeHandle;
this.monochromeFace = monochromeFace;
this.monochromeSelectedFace = monochromeSelectedFace;
}
protected Color GetColor(NamedFace name, Element element)
{
switch(element)
{
default:
case Element.Face: return faceColors[monochromeFace ? 0 : (int)name];
case Element.SelectedFace: return faceColorsSelected[monochromeSelectedFace ? 0 : (int)name];
case Element.Handle: return handleColors[monochromeHandle ? 0 : (int)name];
}
}
public virtual void DrawHull(bool selected)
{
Color colorGizmo = Gizmos.color;
Element element = selected ? Element.SelectedFace : Element.Face;
if (selected)
{
Vector3 xSize = new Vector3(size.z, size.y, 1f);
Gizmos.color = GetColor(NamedFace.Left, element);
Gizmos.DrawMesh(face, center + size.x * .5f * Vector3.left, Quaternion.FromToRotation(Vector3.forward, Vector3.left), xSize);
Gizmos.color = GetColor(NamedFace.Right, element);
Gizmos.DrawMesh(face, center + size.x * .5f * Vector3.right, Quaternion.FromToRotation(Vector3.forward, Vector3.right), xSize);
Vector3 ySize = new Vector3(size.x, size.z, 1f);
Gizmos.color = GetColor(NamedFace.Top, element);
Gizmos.DrawMesh(face, center + size.y * .5f * Vector3.up, Quaternion.FromToRotation(Vector3.forward, Vector3.up), ySize);
Gizmos.color = GetColor(NamedFace.Bottom, element);
Gizmos.DrawMesh(face, center + size.y * .5f * Vector3.down, Quaternion.FromToRotation(Vector3.forward, Vector3.down), ySize);
Vector3 zSize = new Vector3(size.x, size.y, 1f);
Gizmos.color = GetColor(NamedFace.Front, element);
Gizmos.DrawMesh(face, center + size.z * .5f * Vector3.forward, Quaternion.identity, zSize);
Gizmos.color = GetColor(NamedFace.Back, element);
Gizmos.DrawMesh(face, center + size.z * .5f * Vector3.back, Quaternion.FromToRotation(Vector3.forward, Vector3.back), zSize);
}
Gizmos.color = colorGizmo;
Gizmos.DrawWireCube(center, size);
}
//Note: Handles.Slider not allow to use a specific ControlID.
//Thus Slider1D is used (with reflection)
static PropertyInfo k_scale = Type.GetType("UnityEditor.SnapSettings, UnityEditor").GetProperty("scale");
static Type k_Slider1D = Type.GetType("UnityEditorInternal.Slider1D, UnityEditor");
static MethodInfo k_Slider1D_Do = k_Slider1D
.GetMethod(
"Do",
BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public,
null,
CallingConventions.Any,
new[] { typeof(int), typeof(Vector3), typeof(Vector3), typeof(float), typeof(Handles.CapFunction), typeof(float) },
null);
static void Slider1D(int controlID, ref Vector3 handlePosition, Vector3 handleOrientation, float snapScale, Color color)
{
using (new Handles.DrawingScope(color))
{
handlePosition = (Vector3)k_Slider1D_Do.Invoke(null, new object[]
{
controlID,
handlePosition,
handleOrientation,
HandleUtility.GetHandleSize(handlePosition) * k_HandleSizeCoef,
new Handles.CapFunction(Handles.DotHandleCap),
snapScale
});
}
}
public void DrawHandle()
{
for (int i = 0, count = m_ControlIDs.Length; i < count; ++i)
m_ControlIDs[i] = GUIUtility.GetControlID(GetHashCode(), FocusType.Passive);
EditorGUI.BeginChangeCheck();
Vector3 leftPosition = center + size.x * .5f * Vector3.left;
Vector3 rightPosition = center + size.x * .5f * Vector3.right;
Vector3 topPosition = center + size.y * .5f * Vector3.up;
Vector3 bottomPosition = center + size.y * .5f * Vector3.down;
Vector3 frontPosition = center + size.z * .5f * Vector3.forward;
Vector3 backPosition = center + size.z * .5f * Vector3.back;
float snapScale = (float)k_scale.GetValue(null, null);
NamedFace theChangedFace = NamedFace.None;
EditorGUI.BeginChangeCheck();
Slider1D(m_ControlIDs[(int)NamedFace.Left], ref leftPosition, Vector3.left, snapScale, GetColor(NamedFace.Left, Element.Handle));
if (EditorGUI.EndChangeCheck() && allHandleControledByOne)
theChangedFace = NamedFace.Left;
EditorGUI.BeginChangeCheck();
using (new Handles.DrawingScope(GetColor(NamedFace.Right, Element.Handle)))
Slider1D(m_ControlIDs[(int)NamedFace.Right], ref rightPosition, Vector3.right, snapScale, GetColor(NamedFace.Right, Element.Handle));
if (EditorGUI.EndChangeCheck() && allHandleControledByOne)
theChangedFace = NamedFace.Right;
EditorGUI.BeginChangeCheck();
Slider1D(m_ControlIDs[(int)NamedFace.Top], ref topPosition, Vector3.up, snapScale, GetColor(NamedFace.Top, Element.Handle));
if (EditorGUI.EndChangeCheck() && allHandleControledByOne)
theChangedFace = NamedFace.Top;
EditorGUI.BeginChangeCheck();
Slider1D(m_ControlIDs[(int)NamedFace.Bottom], ref bottomPosition, Vector3.down, snapScale, GetColor(NamedFace.Bottom, Element.Handle));
if (EditorGUI.EndChangeCheck() && allHandleControledByOne)
theChangedFace = NamedFace.Bottom;
EditorGUI.BeginChangeCheck();
Slider1D(m_ControlIDs[(int)NamedFace.Front], ref frontPosition, Vector3.forward, snapScale, GetColor(NamedFace.Front, Element.Handle));
if (EditorGUI.EndChangeCheck() && allHandleControledByOne)
theChangedFace = NamedFace.Front;
EditorGUI.BeginChangeCheck();
Slider1D(m_ControlIDs[(int)NamedFace.Back], ref backPosition, Vector3.back, snapScale, GetColor(NamedFace.Back, Element.Handle));
if (EditorGUI.EndChangeCheck() && allHandleControledByOne)
theChangedFace = NamedFace.Back;
if (EditorGUI.EndChangeCheck())
{
if(allHandleControledByOne)
{
float decal = 0f;
switch(theChangedFace)
{
case NamedFace.Left:
decal = (leftPosition - center - size.x * .5f * Vector3.left).x;
break;
case NamedFace.Right:
decal = -(rightPosition - center - size.x * .5f * Vector3.right).x;
break;
case NamedFace.Top:
decal = -(topPosition - center - size.y * .5f * Vector3.up).y;
break;
case NamedFace.Bottom:
decal = (bottomPosition - center - size.y * .5f * Vector3.down).y;
break;
case NamedFace.Front:
decal = -(frontPosition - center - size.z * .5f * Vector3.forward).z;
break;
case NamedFace.Back:
decal = (backPosition - center - size.z * .5f * Vector3.back).z;
break;
}
Vector3 tempSize = size - Vector3.one * decal;
for (int axis = 0; axis < 3; ++axis)
{
if (tempSize[axis] < 0)
{
decal += tempSize[axis];
tempSize = size - Vector3.one * decal;
}
}
size = tempSize;
}
else
{
Vector3 max = new Vector3(rightPosition.x, topPosition.y, frontPosition.z);
Vector3 min = new Vector3(leftPosition.x, bottomPosition.y, backPosition.z);
//ensure that the box face are still facing outside
for (int axis = 0; axis < 3; ++axis)
{
if (min[axis] > max[axis])
{
if (GUIUtility.hotControl == m_ControlIDs[axis])
{
max[axis] = min[axis];
}
else
{
min[axis] = max[axis];
}
}
}
center = (max + min) * .5f;
size = max - min;
}
}
}
}
public class Gizmo6FacesBoxContained : Gizmo6FacesBox
{
private Gizmo6FacesBox m_container;
public Gizmo6FacesBox container
{
get
{
return m_container;
}
set
{
if (value == null)
throw new System.ArgumentNullException("Container cannot be null. Use Gizmo6FacesBox instead.");
m_container = value;
}
}
public Gizmo6FacesBoxContained(Gizmo6FacesBox container, bool monochromeHandle = false, bool monochromeFace = false, bool monochromeSelectedFace = false) : base(monochromeHandle, monochromeFace, monochromeSelectedFace)
{
m_container = container;
}
public override void DrawHull(bool selected)
{
Color colorGizmo = Gizmos.color;
base.DrawHull(selected);
//if selected, also draw handle distance to container here
if (selected)
{
Vector3 centerDiff = center - m_container.center;
Vector3 xRecal = centerDiff;
Vector3 yRecal = centerDiff;
Vector3 zRecal = centerDiff;
xRecal.x = 0;
yRecal.y = 0;
zRecal.z = 0;
Gizmos.color = GetColor(NamedFace.Left, Element.Handle);
Gizmos.DrawLine(m_container.center + xRecal + m_container.size.x * .5f * Vector3.left, center + size.x * .5f * Vector3.left);
Gizmos.color = GetColor(NamedFace.Right, Element.Handle);
Gizmos.DrawLine(m_container.center + xRecal + m_container.size.x * .5f * Vector3.right, center + size.x * .5f * Vector3.right);
Gizmos.color = GetColor(NamedFace.Top, Element.Handle);
Gizmos.DrawLine(m_container.center + yRecal + m_container.size.y * .5f * Vector3.up, center + size.y * .5f * Vector3.up);
Gizmos.color = GetColor(NamedFace.Bottom, Element.Handle);
Gizmos.DrawLine(m_container.center + yRecal + m_container.size.y * .5f * Vector3.down, center + size.y * .5f * Vector3.down);
Gizmos.color = GetColor(NamedFace.Front, Element.Handle);
Gizmos.DrawLine(m_container.center + zRecal + m_container.size.z * .5f * Vector3.forward, center + size.z * .5f * Vector3.forward);
Gizmos.color = GetColor(NamedFace.Back, Element.Handle);
Gizmos.DrawLine(m_container.center + zRecal + m_container.size.z * .5f * Vector3.back, center + size.z * .5f * Vector3.back);
}
Gizmos.color = colorGizmo;
}
}
}
正在加载...
取消
保存