浏览代码
Merge pull request #1813 from Unity-Technologies/HDRP/refactor-reflectionProbe/merge-probe-editors
Merge pull request #1813 from Unity-Technologies/HDRP/refactor-reflectionProbe/merge-probe-editors
Hdrp/refactor reflection probe/merge probe editors/main
GitHub
6 年前
当前提交
543c68af
共有 54 个文件被更改,包括 1783 次插入 和 1929 次删除
-
29com.unity.render-pipelines.core/CoreRP/Editor/CoreEditorUtils.cs
-
3com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/EditorReflectionSystem.cs
-
2com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDReflectionProbeEditor.Gizmos.cs
-
34com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDReflectionProbeEditor.Preview.cs
-
2com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDReflectionProbeEditor.ProbeUtility.cs
-
133com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDReflectionProbeEditor.cs
-
532com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDReflectionProbeUI.Drawers.cs
-
102com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDReflectionProbeUI.cs
-
89com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/PlanarReflectionProbeEditor.cs
-
2com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/PlanarReflectionProbeEditor.cs.meta
-
212com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/PlanarReflectionProbeUI.Handles.cs
-
2com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/PlanarReflectionProbeUI.Handles.cs.meta
-
121com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/PlanarReflectionProbeUI.cs
-
2com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/PlanarReflectionProbeUI.cs.meta
-
109com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/SerializedHDReflectionProbe.cs
-
81com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/SerializedPlanarReflectionProbe.cs
-
163com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/Volume/InfluenceVolumeUI.Drawers.cs
-
311com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/Volume/InfluenceVolumeUI.Handles.cs
-
20com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/Volume/InfluenceVolumeUI.cs
-
135com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/Volume/ProxyVolumeUI.cs
-
9com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/Volume/ReflectionProxyVolumeComponentUI.cs
-
29com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/Volume/SerializedInfluenceVolume.cs
-
2com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDProbeUI.ContextualMenu.cs
-
4com.unity.render-pipelines.high-definition/HDRP/Lighting/LightLoop/LightLoop.cs
-
10com.unity.render-pipelines.high-definition/HDRP/Lighting/LightLoop/LightLoopDef.hlsl
-
69com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/HDAdditionalReflectionData.cs
-
25com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/HDProbe.cs
-
19com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/PlanarReflectionProbe.cs
-
29com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/ProbeWrapper.cs
-
10com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/ReflectionSystem.cs
-
166com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/ReflectionSystemInternal.cs
-
14com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/ReflectionSystemParameters.cs
-
16com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/Volumes/InfluenceVolume.cs
-
8com.unity.render-pipelines.high-definition/HDRP/RenderPipeline/HDRenderPipeline.cs
-
4com.unity.render-pipelines.high-definition/HDRP/RenderPipeline/HDRenderPipelineAsset.cs
-
80com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDProbeEditor.cs
-
11com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDProbeEditor.cs.meta
-
297com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDProbeUI.Drawers.cs
-
101com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDProbeUI.Handles.cs
-
11com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDProbeUI.Handles.cs.meta
-
77com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDProbeUI.Skin.cs
-
11com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDProbeUI.Skin.cs.meta
-
90com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDProbeUI.cs
-
11com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDProbeUI.cs.meta
-
57com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/SerializedHDProbe.cs
-
11com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/SerializedHDProbe.cs.meta
-
34com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/Volume/InfluenceVolumeUI.Skin.cs
-
11com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/Volume/InfluenceVolumeUI.Skin.cs.meta
-
11com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDReflectionProbeEditor.Handles.cs.meta
-
312com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/PlanarReflectionProbeUI.Drawers.cs
-
89com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDReflectionProbeEditor.Handles.cs
-
0/com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDProbeUI.Drawers.cs.meta
-
0/com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDProbeUI.ContextualMenu.cs.meta
-
0/com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDProbeUI.ContextualMenu.cs
|
|||
using System; |
|||
using UnityEditor.AnimatedValues; |
|||
using UnityEngine.Events; |
|||
using UnityEngine.Experimental.Rendering.HDPipeline; |
|||
using UnityEngine.Rendering; |
|||
|
|||
partial class PlanarReflectionProbeUI : BaseUI<SerializedPlanarReflectionProbe> |
|||
using UnityEngine; |
|||
using UnityEngine.Experimental.Rendering.HDPipeline; |
|||
using UnityEngine.Rendering; |
|||
using CED = CoreEditorDrawer<HDProbeUI, SerializedHDProbe>; |
|||
|
|||
partial class PlanarReflectionProbeUI : HDProbeUI |
|||
const int k_AnimBoolFields = 6; |
|||
static readonly int k_ReflectionProbeModeModeCount = Enum.GetValues(typeof(ReflectionProbeMode)).Length; |
|||
static readonly int k_AnimBoolTotal = k_AnimBoolFields + k_ReflectionProbeModeModeCount; |
|||
static readonly GUIContent overrideFieldOfViewContent = CoreEditorUtils.GetContent("Override Field Of View"); |
|||
static readonly GUIContent fieldOfViewSolidAngleContent = CoreEditorUtils.GetContent("Field Of View"); |
|||
public InfluenceVolumeUI influenceVolume = new InfluenceVolumeUI(); |
|||
public FrameSettingsUI frameSettings = new FrameSettingsUI(); |
|||
public ReflectionProxyVolumeComponentUI reflectionProxyVolume = new ReflectionProxyVolumeComponentUI(); |
|||
public static CED.IDrawer Inspector; |
|||
|
|||
public static readonly CED.IDrawer SectionFoldoutCaptureSettings = CED.FoldoutGroup( |
|||
"Capture Settings", |
|||
(s, d, o) => s.isSectionExpandedCaptureSettings, |
|||
FoldoutOption.Indent, |
|||
CED.Action(Drawer_SectionCaptureSettings) |
|||
); |
|||
public AnimBool isSectionExpandedInfluenceSettings { get { return m_AnimBools[k_ReflectionProbeModeModeCount]; } } |
|||
public AnimBool isSectionExpandedCaptureSettings { get { return m_AnimBools[k_ReflectionProbeModeModeCount + 1]; } } |
|||
|
|||
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; } |
|||
|
|||
public PlanarReflectionProbeUI() |
|||
: base(k_AnimBoolTotal) |
|||
static PlanarReflectionProbeUI() |
|||
isSectionExpandedInfluenceSettings.value = true; |
|||
isSectionExpandedCaptureSettings.value = true; |
|||
isSectionExpendedProxyVolume.value = true; |
|||
isSectionExpendedAdditionalSettings.value = false; |
|||
Inspector = CED.Group( |
|||
CED.Action(Drawer_Toolbars), |
|||
CED.space, |
|||
ProxyVolumeSettings, |
|||
CED.Select( |
|||
(s, d, o) => s.influenceVolume, |
|||
(s, d, o) => d.influenceVolume, |
|||
InfluenceVolumeUI.SectionFoldoutShapePlanar |
|||
), |
|||
CED.Action(Drawer_DifferentShapeError), |
|||
SectionFoldoutCaptureSettings, |
|||
SectionFoldoutAdditionalSettings, |
|||
CED.Select( |
|||
(s, d, o) => s.frameSettings, |
|||
(s, d, o) => d.frameSettings, |
|||
FrameSettingsUI.Inspector |
|||
), |
|||
CED.space, |
|||
CED.Action(Drawer_SectionBakeButton) |
|||
); |
|||
public AnimBool IsSectionExpandedReflectionProbeMode(ReflectionProbeMode mode) |
|||
protected static void Drawer_SectionCaptureSettings(HDProbeUI s, SerializedHDProbe d, Editor o) |
|||
return m_AnimBools[(int)mode]; |
|||
SerializedPlanarReflectionProbe serialized = (SerializedPlanarReflectionProbe)d; |
|||
var hdrp = GraphicsSettings.renderPipelineAsset as HDRenderPipelineAsset; |
|||
GUI.enabled = false; |
|||
EditorGUILayout.LabelField( |
|||
CoreEditorUtils.GetContent("Probe Texture Size (Set By HDRP)"), |
|||
CoreEditorUtils.GetContent(hdrp.renderPipelineSettings.lightLoopSettings.planarReflectionTextureSize.ToString()), |
|||
EditorStyles.label); |
|||
EditorGUILayout.Toggle( |
|||
CoreEditorUtils.GetContent("Probe Compression (Set By HDRP)"), |
|||
hdrp.renderPipelineSettings.lightLoopSettings.planarReflectionCacheCompressed); |
|||
GUI.enabled = true; |
|||
|
|||
bool on = serialized.overrideFieldOfView.boolValue; |
|||
EditorGUI.BeginChangeCheck(); |
|||
on = EditorGUILayout.Toggle(overrideFieldOfViewContent, on); |
|||
if (on) |
|||
{ |
|||
serialized.fieldOfViewOverride.floatValue = EditorGUILayout.FloatField(fieldOfViewSolidAngleContent, serialized.fieldOfViewOverride.floatValue); |
|||
} |
|||
if (EditorGUI.EndChangeCheck()) |
|||
{ |
|||
serialized.overrideFieldOfView.boolValue = on; |
|||
serialized.Apply(); |
|||
} |
|||
|
|||
//GUI.enabled = false;
|
|||
//EditorGUILayout.LabelField(resolutionContent, CoreEditorUtils.GetContent(((int)hdrp.GetRenderPipelineSettings().lightLoopSettings.reflectionCubemapSize).ToString()));
|
|||
//EditorGUILayout.LabelField(shadowDistanceContent, EditorStyles.label);
|
|||
//EditorGUILayout.LabelField(cullingMaskContent, EditorStyles.label);
|
|||
//EditorGUILayout.LabelField(useOcclusionCullingContent, EditorStyles.label);
|
|||
//EditorGUILayout.LabelField(nearClipCullingContent, EditorStyles.label);
|
|||
//EditorGUILayout.LabelField(farClipCullingContent, EditorStyles.label);
|
|||
//GUI.enabled = true;
|
|||
public override void Reset(SerializedPlanarReflectionProbe data, UnityAction repaint) |
|||
internal PlanarReflectionProbeUI() |
|||
reflectionProxyVolume.Reset(data.reflectionProxyVolume, repaint); |
|||
frameSettings.Reset(data.frameSettings, repaint); |
|||
influenceVolume.Reset(data.influenceVolume, repaint); |
|||
base.Reset(data, repaint); |
|||
toolBars = new[] { ToolBar.InfluenceShape | ToolBar.Blend }; |
|||
for (var i = 0; i < k_ReflectionProbeModeModeCount; i++) |
|||
m_AnimBools[i].target = i == data.mode.intValue; |
|||
|
|||
isSectionExpandedCaptureMirrorSettings.target = data.isMirrored; |
|||
isSectionExpandedCaptureStaticSettings.target = !data.isMirrored; |
|||
|
|||
reflectionProxyVolume.Update(); |
|||
frameSettings.Update(); |
|||
influenceVolume.Update(); |
|||
SerializedPlanarReflectionProbe serialized = data as SerializedPlanarReflectionProbe; |
|||
isSectionExpandedCaptureMirrorSettings.target = serialized.isMirrored; |
|||
isSectionExpandedCaptureStaticSettings.target = !serialized.isMirrored; |
|||
base.Update(); |
|||
} |
|||
} |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Reflection; |
|||
using UnityEditor.Callbacks; |
|||
using UnityEngine; |
|||
using UnityEngine.Experimental.Rendering; |
|||
using UnityEngine.Experimental.Rendering.HDPipeline; |
|||
using Object = UnityEngine.Object; |
|||
|
|||
namespace UnityEditor.Experimental.Rendering.HDPipeline |
|||
{ |
|||
abstract class HDProbeEditor : Editor |
|||
{ |
|||
static Dictionary<HDProbe, HDProbeUI> s_StateMap = new Dictionary<HDProbe, HDProbeUI>(); |
|||
|
|||
internal static bool TryGetUIStateFor(HDProbe p, out HDProbeUI r) |
|||
{ |
|||
return s_StateMap.TryGetValue(p, out r); |
|||
} |
|||
|
|||
internal abstract HDProbe GetTarget(Object editorTarget); |
|||
|
|||
protected SerializedHDProbe m_SerializedHDProbe; |
|||
HDProbeUI m_UIState; |
|||
HDProbeUI[] m_UIHandleState; |
|||
protected HDProbe[] m_TypedTargets; |
|||
|
|||
protected virtual void OnEnable() |
|||
{ |
|||
if(m_UIState == null) |
|||
{ |
|||
m_UIState = HDProbeUI.CreateFor(this); |
|||
} |
|||
m_UIState.Reset(m_SerializedHDProbe, Repaint); |
|||
|
|||
m_TypedTargets = new HDProbe[targets.Length]; |
|||
m_UIHandleState = new HDProbeUI[m_TypedTargets.Length]; |
|||
for (var i = 0; i < m_TypedTargets.Length; i++) |
|||
{ |
|||
m_TypedTargets[i] = GetTarget(targets[i]); |
|||
m_UIHandleState[i] = HDProbeUI.CreateFor(m_TypedTargets[i]); |
|||
m_UIHandleState[i].Reset(m_SerializedHDProbe, null); |
|||
|
|||
s_StateMap[m_TypedTargets[i]] = m_UIHandleState[i]; |
|||
} |
|||
} |
|||
|
|||
protected virtual void OnDisable() |
|||
{ |
|||
for (var i = 0; i < m_TypedTargets.Length; i++) |
|||
s_StateMap.Remove(m_TypedTargets[i]); |
|||
} |
|||
|
|||
protected abstract void Draw(HDProbeUI s, SerializedHDProbe serialized, Editor owner); |
|||
|
|||
public override void OnInspectorGUI() |
|||
{ |
|||
var s = m_UIState; |
|||
var d = m_SerializedHDProbe; |
|||
var o = this; |
|||
|
|||
s.Update(); |
|||
d.Update(); |
|||
|
|||
Draw(s, d, o); |
|||
|
|||
d.Apply(); |
|||
} |
|||
|
|||
protected virtual void OnSceneGUI() |
|||
{ |
|||
//mandatory update as for strange reason the serialized rollback one update here
|
|||
m_UIState.Update(); |
|||
m_SerializedHDProbe.Update(); |
|||
|
|||
HDProbeUI.DrawHandles(m_UIState, m_SerializedHDProbe, this); |
|||
m_UIState.DoShortcutKey(this); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 7f189b572cf7bf04d9f1976dcc75c942 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using UnityEditorInternal; |
|||
using UnityEngine; |
|||
using UnityEngine.Experimental.Rendering.HDPipeline; |
|||
using UnityEngine.Rendering; |
|||
|
|||
namespace UnityEditor.Experimental.Rendering.HDPipeline |
|||
{ |
|||
using _ = CoreEditorUtils; |
|||
using CED = CoreEditorDrawer<HDProbeUI, SerializedHDProbe>; |
|||
|
|||
partial class HDProbeUI |
|||
{ |
|||
public static readonly CED.IDrawer SectionProbeModeSettings; |
|||
public static readonly CED.IDrawer ProxyVolumeSettings = CED.FoldoutGroup( |
|||
proxySettingsHeader, |
|||
(s, d, o) => s.isSectionExpendedProxyVolume, |
|||
FoldoutOption.Indent, |
|||
CED.Action(Drawer_SectionProxySettings) |
|||
); |
|||
public static readonly CED.IDrawer SectionProbeModeBakedSettings = CED.noop; |
|||
public static readonly CED.IDrawer SectionProbeModeRealtimeSettings = CED.Action(Drawer_SectionProbeModeRealtimeSettings); |
|||
public static readonly CED.IDrawer SectionBakeButton = CED.Action(Drawer_SectionBakeButton); |
|||
|
|||
public static readonly CED.IDrawer SectionFoldoutAdditionalSettings = CED.FoldoutGroup( |
|||
additionnalSettingsHeader, |
|||
(s, d, o) => s.isSectionExpendedAdditionalSettings, |
|||
FoldoutOption.Indent, |
|||
CED.Action(Drawer_SectionCustomSettings) |
|||
); |
|||
|
|||
static HDProbeUI() |
|||
{ |
|||
SectionProbeModeSettings = CED.Group( |
|||
CED.Action(Drawer_FieldCaptureType), |
|||
CED.FadeGroup( |
|||
(s, d, o, i) => s.IsSectionExpandedReflectionProbeMode((ReflectionProbeMode)i), |
|||
FadeOption.Indent, |
|||
SectionProbeModeBakedSettings, |
|||
SectionProbeModeRealtimeSettings |
|||
) |
|||
); |
|||
} |
|||
|
|||
protected static void Drawer_DifferentShapeError(HDProbeUI s, SerializedHDProbe d, Editor o) |
|||
{ |
|||
var proxy = d.proxyVolumeReference.objectReferenceValue as ReflectionProxyVolumeComponent; |
|||
if (proxy != null |
|||
&& (int)proxy.proxyVolume.shape != d.influenceVolume.shape.enumValueIndex |
|||
&& proxy.proxyVolume.shape != ProxyShape.Infinite) |
|||
{ |
|||
EditorGUILayout.HelpBox( |
|||
proxyInfluenceShapeMismatchHelpBoxText, |
|||
MessageType.Error, |
|||
true |
|||
); |
|||
} |
|||
} |
|||
|
|||
static GUIStyle disabled; |
|||
static void PropertyField(SerializedProperty prop, GUIContent content) |
|||
{ |
|||
if(prop != null) |
|||
{ |
|||
EditorGUILayout.PropertyField(prop, content); |
|||
} |
|||
else |
|||
{ |
|||
if(disabled == null) |
|||
{ |
|||
disabled = new GUIStyle(GUI.skin.label); |
|||
disabled.onNormal.textColor *= 0.5f; |
|||
} |
|||
EditorGUILayout.LabelField(content, disabled); |
|||
} |
|||
} |
|||
|
|||
protected static void Drawer_SectionBakeButton(HDProbeUI s, SerializedHDProbe d, Editor o) |
|||
{ |
|||
if (d.target is HDAdditionalReflectionData) |
|||
EditorReflectionSystemGUI.DrawBakeButton((ReflectionProbeMode)d.mode.intValue, ((HDAdditionalReflectionData)d.target).reflectionProbe); |
|||
else //PlanarReflectionProbe
|
|||
EditorReflectionSystemGUI.DrawBakeButton((ReflectionProbeMode)d.mode.intValue, d.target as PlanarReflectionProbe); |
|||
} |
|||
|
|||
static void Drawer_SectionProbeModeRealtimeSettings(HDProbeUI s, SerializedHDProbe d, Editor o) |
|||
{ |
|||
GUI.enabled = false; |
|||
EditorGUILayout.PropertyField(d.refreshMode, _.GetContent("Refresh Mode")); |
|||
GUI.enabled = true; |
|||
} |
|||
|
|||
protected static void Drawer_SectionProxySettings(HDProbeUI s, SerializedHDProbe d, Editor o) |
|||
{ |
|||
EditorGUILayout.PropertyField(d.proxyVolumeReference, proxyVolumeContent); |
|||
|
|||
if (d.target.proxyVolume == null) |
|||
{ |
|||
EditorGUI.BeginChangeCheck(); |
|||
d.infiniteProjection.boolValue = !EditorGUILayout.Toggle(useInfiniteProjectionContent, !d.infiniteProjection.boolValue); |
|||
if(EditorGUI.EndChangeCheck()) |
|||
{ |
|||
d.Apply(); |
|||
} |
|||
} |
|||
|
|||
if (d.proxyVolumeReference.objectReferenceValue != null) |
|||
{ |
|||
var proxy = (ReflectionProxyVolumeComponent)d.proxyVolumeReference.objectReferenceValue; |
|||
if ((int)proxy.proxyVolume.shape != d.influenceVolume.shape.enumValueIndex |
|||
&& proxy.proxyVolume.shape != ProxyShape.Infinite) |
|||
EditorGUILayout.HelpBox( |
|||
proxyInfluenceShapeMismatchHelpBoxText, |
|||
MessageType.Error, |
|||
true |
|||
); |
|||
} |
|||
else |
|||
{ |
|||
EditorGUILayout.HelpBox( |
|||
d.infiniteProjection.boolValue ? noProxyInfiniteHelpBoxText : noProxyHelpBoxText, |
|||
MessageType.Info, |
|||
true |
|||
); |
|||
} |
|||
} |
|||
|
|||
protected static void Drawer_SectionCustomSettings(HDProbeUI s, SerializedHDProbe d, Editor o) |
|||
{ |
|||
EditorGUILayout.PropertyField(d.weight, weightContent); |
|||
|
|||
EditorGUI.BeginChangeCheck(); |
|||
EditorGUILayout.PropertyField(d.multiplier, multiplierContent); |
|||
if (EditorGUI.EndChangeCheck()) |
|||
d.multiplier.floatValue = Mathf.Max(0.0f, d.multiplier.floatValue); |
|||
} |
|||
|
|||
static void Drawer_FieldCaptureType(HDProbeUI s, SerializedHDProbe d, Editor o) |
|||
{ |
|||
GUI.enabled = false; |
|||
EditorGUILayout.PropertyField(d.mode, fieldCaptureTypeContent); |
|||
GUI.enabled = true; |
|||
} |
|||
|
|||
|
|||
[Flags] |
|||
internal enum ToolBar |
|||
{ |
|||
InfluenceShape = 1<<0, |
|||
Blend = 1<<1, |
|||
NormalBlend = 1<<2, |
|||
CapturePosition = 1<<3 |
|||
} |
|||
protected ToolBar[] toolBars = null; |
|||
|
|||
protected const EditMode.SceneViewEditMode EditBaseShape = EditMode.SceneViewEditMode.ReflectionProbeBox; |
|||
protected const EditMode.SceneViewEditMode EditInfluenceShape = EditMode.SceneViewEditMode.GridBox; |
|||
protected const EditMode.SceneViewEditMode EditInfluenceNormalShape = EditMode.SceneViewEditMode.Collider; |
|||
protected const EditMode.SceneViewEditMode EditCenter = EditMode.SceneViewEditMode.GridMove; |
|||
//Note: EditMode.SceneViewEditMode.ReflectionProbeOrigin is still used
|
|||
//by legacy reflection probe and have its own mecanism that we don't want
|
|||
|
|||
internal static bool IsProbeEditMode(EditMode.SceneViewEditMode editMode) |
|||
{ |
|||
return editMode == EditBaseShape |
|||
|| editMode == EditInfluenceShape |
|||
|| editMode == EditInfluenceNormalShape |
|||
|| editMode == EditCenter; |
|||
} |
|||
|
|||
static Dictionary<ToolBar, EditMode.SceneViewEditMode> s_Toolbar_Mode = null; |
|||
protected static Dictionary<ToolBar, EditMode.SceneViewEditMode> toolbar_Mode |
|||
{ |
|||
get |
|||
{ |
|||
return s_Toolbar_Mode ?? (s_Toolbar_Mode = new Dictionary<ToolBar, EditMode.SceneViewEditMode> |
|||
{ |
|||
{ ToolBar.InfluenceShape, EditBaseShape }, |
|||
{ ToolBar.Blend, EditInfluenceShape }, |
|||
{ ToolBar.NormalBlend, EditInfluenceNormalShape }, |
|||
{ ToolBar.CapturePosition, EditCenter } |
|||
}); |
|||
} |
|||
} |
|||
|
|||
//[TODO] change this to be modifiable shortcuts
|
|||
static Dictionary<KeyCode, ToolBar> s_Toolbar_ShortCutKey = null; |
|||
protected static Dictionary<KeyCode, ToolBar> toolbar_ShortCutKey |
|||
{ |
|||
get |
|||
{ |
|||
return s_Toolbar_ShortCutKey ?? (s_Toolbar_ShortCutKey = new Dictionary<KeyCode, ToolBar> |
|||
{ |
|||
{ KeyCode.Alpha1, ToolBar.InfluenceShape }, |
|||
{ KeyCode.Alpha2, ToolBar.Blend }, |
|||
{ KeyCode.Alpha3, ToolBar.NormalBlend }, |
|||
{ KeyCode.Alpha4, ToolBar.CapturePosition } |
|||
}); |
|||
} |
|||
} |
|||
|
|||
protected static void Drawer_Toolbars(HDProbeUI s, SerializedHDProbe d, Editor o) |
|||
{ |
|||
GUILayout.BeginHorizontal(); |
|||
GUILayout.FlexibleSpace(); |
|||
GUI.changed = false; |
|||
|
|||
foreach(ToolBar toolBar in s.toolBars) |
|||
{ |
|||
List<EditMode.SceneViewEditMode> listMode = new List<EditMode.SceneViewEditMode>(); |
|||
List<GUIContent> listContent = new List<GUIContent>(); |
|||
if ((toolBar & ToolBar.InfluenceShape) > 0) |
|||
{ |
|||
listMode.Add(toolbar_Mode[ToolBar.InfluenceShape]); |
|||
listContent.Add(toolbar_Contents[ToolBar.InfluenceShape]); |
|||
} |
|||
if ((toolBar & ToolBar.Blend) > 0) |
|||
{ |
|||
listMode.Add(toolbar_Mode[ToolBar.Blend]); |
|||
listContent.Add(toolbar_Contents[ToolBar.Blend]); |
|||
} |
|||
if ((toolBar & ToolBar.NormalBlend) > 0) |
|||
{ |
|||
listMode.Add(toolbar_Mode[ToolBar.NormalBlend]); |
|||
listContent.Add(toolbar_Contents[ToolBar.NormalBlend]); |
|||
} |
|||
if ((toolBar & ToolBar.CapturePosition) > 0) |
|||
{ |
|||
listMode.Add(toolbar_Mode[ToolBar.CapturePosition]); |
|||
listContent.Add(toolbar_Contents[ToolBar.CapturePosition]); |
|||
} |
|||
EditMode.DoInspectorToolbar(listMode.ToArray(), listContent.ToArray(), GetBoundsGetter(o), o); |
|||
} |
|||
GUILayout.FlexibleSpace(); |
|||
GUILayout.EndHorizontal(); |
|||
} |
|||
|
|||
|
|||
static internal void Drawer_ToolBarButton(ToolBar button, Editor owner, params GUILayoutOption[] options) |
|||
{ |
|||
bool enabled = toolbar_Mode[button] == EditMode.editMode; |
|||
EditorGUI.BeginChangeCheck(); |
|||
enabled = GUILayout.Toggle(enabled, toolbar_Contents[button], EditorStyles.miniButton, options); |
|||
if (EditorGUI.EndChangeCheck()) |
|||
{ |
|||
EditMode.SceneViewEditMode targetMode = EditMode.editMode == toolbar_Mode[button] ? EditMode.SceneViewEditMode.None : toolbar_Mode[button]; |
|||
EditMode.ChangeEditMode(targetMode, GetBoundsGetter(owner)(), owner); |
|||
} |
|||
} |
|||
|
|||
static Func<Bounds> GetBoundsGetter(Editor o) |
|||
{ |
|||
return () => |
|||
{ |
|||
var bounds = new Bounds(); |
|||
foreach (Component targetObject in o.targets) |
|||
{ |
|||
var rp = targetObject.transform; |
|||
var b = rp.position; |
|||
bounds.Encapsulate(b); |
|||
} |
|||
return bounds; |
|||
}; |
|||
} |
|||
|
|||
public void DoShortcutKey(Editor owner) |
|||
{ |
|||
var evt = Event.current; |
|||
if (evt.type != EventType.KeyDown || !evt.shift) |
|||
return; |
|||
|
|||
ToolBar toolbar; |
|||
if(toolbar_ShortCutKey.TryGetValue(evt.keyCode, out toolbar)) |
|||
{ |
|||
bool used = false; |
|||
foreach(ToolBar t in toolBars) |
|||
{ |
|||
if((t&toolbar)>0) |
|||
{ |
|||
used = true; |
|||
break; |
|||
} |
|||
} |
|||
if (!used) |
|||
{ |
|||
return; |
|||
} |
|||
|
|||
var targetMode = toolbar_Mode[toolbar]; |
|||
var mode = EditMode.editMode == targetMode ? EditMode.SceneViewEditMode.None : targetMode; |
|||
EditMode.ChangeEditMode(mode, GetBoundsGetter(owner)(), owner); |
|||
evt.Use(); |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
using UnityEditorInternal; |
|||
using UnityEngine; |
|||
using UnityEngine.Experimental.Rendering.HDPipeline; |
|||
|
|||
namespace UnityEditor.Experimental.Rendering.HDPipeline |
|||
{ |
|||
partial class HDProbeUI |
|||
{ |
|||
|
|||
internal static void DrawHandles(HDProbeUI s, SerializedHDProbe d, Editor o) |
|||
{ |
|||
HDProbe probe = d.target as HDProbe; |
|||
var mat = Matrix4x4.TRS(probe.transform.position, probe.transform.rotation, Vector3.one); |
|||
|
|||
switch (EditMode.editMode) |
|||
{ |
|||
case EditBaseShape: |
|||
InfluenceVolumeUI.DrawHandles_EditBase(s.influenceVolume, d.influenceVolume, o, mat, probe); |
|||
break; |
|||
case EditInfluenceShape: |
|||
InfluenceVolumeUI.DrawHandles_EditInfluence(s.influenceVolume, d.influenceVolume, o, mat, probe); |
|||
break; |
|||
case EditInfluenceNormalShape: |
|||
InfluenceVolumeUI.DrawHandles_EditInfluenceNormal(s.influenceVolume, d.influenceVolume, o, mat, probe); |
|||
break; |
|||
case EditCenter: |
|||
{ |
|||
using (new Handles.DrawingScope(Matrix4x4.TRS(Vector3.zero, Quaternion.identity, Vector3.one))) |
|||
{ |
|||
Vector3 offsetWorld = probe.transform.position + probe.transform.rotation * probe.influenceVolume.offset; |
|||
EditorGUI.BeginChangeCheck(); |
|||
var newOffsetWorld = Handles.PositionHandle(offsetWorld, probe.transform.rotation); |
|||
if (EditorGUI.EndChangeCheck()) |
|||
{ |
|||
Vector3 newOffset = Quaternion.Inverse(probe.transform.rotation) * (newOffsetWorld - probe.transform.position); |
|||
Undo.RecordObjects(new Object[] { probe, probe.transform }, "Translate Influence Position"); |
|||
d.influenceVolume.offset.vector3Value = newOffset; |
|||
d.influenceVolume.Apply(); |
|||
|
|||
//call modification to legacy ReflectionProbe
|
|||
probe.influenceVolume.offset = newOffset; |
|||
} |
|||
} |
|||
break; |
|||
} |
|||
} |
|||
} |
|||
|
|||
[DrawGizmo(GizmoType.Selected)] |
|||
internal static void DrawGizmos(HDProbe d, GizmoType gizmoType) |
|||
{ |
|||
HDProbeUI s; |
|||
if (!HDProbeEditor.TryGetUIStateFor(d, out s)) |
|||
return; |
|||
|
|||
var mat = Matrix4x4.TRS(d.transform.position, d.transform.rotation, Vector3.one); |
|||
|
|||
switch (EditMode.editMode) |
|||
{ |
|||
case EditBaseShape: |
|||
InfluenceVolumeUI.DrawGizmos( |
|||
s.influenceVolume, d.influenceVolume, mat, |
|||
InfluenceVolumeUI.HandleType.Base, |
|||
InfluenceVolumeUI.HandleType.All); |
|||
break; |
|||
case EditInfluenceShape: |
|||
InfluenceVolumeUI.DrawGizmos( |
|||
s.influenceVolume, |
|||
d.influenceVolume, |
|||
mat, |
|||
InfluenceVolumeUI.HandleType.Influence, |
|||
InfluenceVolumeUI.HandleType.All); |
|||
break; |
|||
case EditInfluenceNormalShape: |
|||
InfluenceVolumeUI.DrawGizmos( |
|||
s.influenceVolume, |
|||
d.influenceVolume, |
|||
mat, |
|||
InfluenceVolumeUI.HandleType.InfluenceNormal, |
|||
InfluenceVolumeUI.HandleType.All); |
|||
break; |
|||
default: |
|||
{ |
|||
var showedHandles = s.influenceVolume.showInfluenceHandles |
|||
? InfluenceVolumeUI.HandleType.All |
|||
: InfluenceVolumeUI.HandleType.Base; |
|||
InfluenceVolumeUI.DrawGizmos( |
|||
s.influenceVolume, |
|||
d.influenceVolume, |
|||
mat, |
|||
InfluenceVolumeUI.HandleType.None, |
|||
showedHandles); |
|||
break; |
|||
} |
|||
} |
|||
|
|||
if (d.proxyVolume != null) |
|||
ReflectionProxyVolumeComponentUI.DrawGizmos_EditNone(d.proxyVolume); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 8ee668677cd59784d8fb06a531b49a77 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using UnityEditor.AnimatedValues; |
|||
using UnityEngine; |
|||
using UnityEngine.Events; |
|||
using UnityEngine.Experimental.Rendering.HDPipeline; |
|||
using UnityEngine.Rendering; |
|||
|
|||
namespace UnityEditor.Experimental.Rendering.HDPipeline |
|||
{ |
|||
partial class HDProbeUI |
|||
{ |
|||
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) |
|||
} |
|||
}; |
|||
|
|||
static readonly GUIContent bakeTypeContent = CoreEditorUtils.GetContent("Type|'Baked Cubemap' uses the 'Auto Baking' mode from the Lighting window. If it is enabled then baking is automatic otherwise manual bake is needed (use the bake button below). \n'Custom' can be used if a custom cubemap is wanted. \n'Realtime' can be used to dynamically re-render the cubemap during runtime (via scripting)."); |
|||
|
|||
static readonly GUIContent proxyVolumeContent = CoreEditorUtils.GetContent("Proxy Volume"); |
|||
protected static readonly GUIContent useInfiniteProjectionContent = CoreEditorUtils.GetContent("Same As Influence Volume|If enabled, parallax correction will occure, causing 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. When disabled, 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 readonly GUIContent normalModeContent = CoreEditorUtils.GetContent("Normal|Normal parameters mode (only change for box shape)."); |
|||
static readonly GUIContent advancedModeContent = CoreEditorUtils.GetContent("Advanced|Advanced parameters mode (only change for box shape)."); |
|||
|
|||
protected static readonly GUIContent fieldCaptureTypeContent = CoreEditorUtils.GetContent("Type"); |
|||
protected static readonly GUIContent resolutionContent = CoreEditorUtils.GetContent("Resolution"); |
|||
protected static readonly GUIContent shadowDistanceContent = CoreEditorUtils.GetContent("Shadow Distance"); |
|||
protected static readonly GUIContent cullingMaskContent = CoreEditorUtils.GetContent("Culling Mask"); |
|||
protected static readonly GUIContent useOcclusionCullingContent = CoreEditorUtils.GetContent("Use Occlusion Culling"); |
|||
protected static readonly GUIContent nearClipCullingContent = CoreEditorUtils.GetContent("Near Clip"); |
|||
protected static readonly GUIContent farClipCullingContent = CoreEditorUtils.GetContent("Far Clip"); |
|||
|
|||
static readonly GUIContent weightContent = CoreEditorUtils.GetContent("Weight|Blend weight applied on this reflection probe. This can be used for fading in or out a reflection probe."); |
|||
static readonly GUIContent multiplierContent = CoreEditorUtils.GetContent("Intensity Multiplier|Allows you to boost or dimmer the reflected cubemap. Values above 1 will make reflections brighter and values under 1 will make reflections darker. Using values different than 1 is not physically correct."); |
|||
|
|||
static readonly GUIContent textureSizeContent = CoreEditorUtils.GetContent("Probe Texture Size (Set By HDRP)"); |
|||
static readonly GUIContent compressionTextureContent = CoreEditorUtils.GetContent("Probe Compression (Set By HDRP)"); |
|||
|
|||
|
|||
const string mimapHelpBoxText = "No mipmaps in the cubemap, Smoothness value in Standard shader will be ignored."; |
|||
const string noProxyHelpBoxText = "Influence shape will be used as Projection shape too."; |
|||
const string noProxyInfiniteHelpBoxText = "Projection will be at infinite."; |
|||
const string proxyInfluenceShapeMismatchHelpBoxText = "Proxy volume and influence volume have different shapes, this is not supported."; |
|||
|
|||
const string proxySettingsHeader = "Projection Settings"; |
|||
//influenceVolume have its own header
|
|||
protected const string captureSettingsHeader = "Capture Settings"; |
|||
const string additionnalSettingsHeader = "Custom Settings"; |
|||
|
|||
static Dictionary<ToolBar, GUIContent> s_Toolbar_Contents = null; |
|||
protected static Dictionary<ToolBar, GUIContent> toolbar_Contents |
|||
{ |
|||
get |
|||
{ |
|||
return s_Toolbar_Contents ?? (s_Toolbar_Contents = new Dictionary<ToolBar, GUIContent> |
|||
{ |
|||
{ ToolBar.InfluenceShape, EditorGUIUtility.IconContent("EditCollider", "|Modify the base shape. (SHIFT+1)") }, |
|||
{ ToolBar.Blend, EditorGUIUtility.IconContent("PreMatCube", "|Modify the influence volume. (SHIFT+2)") }, |
|||
{ ToolBar.NormalBlend, EditorGUIUtility.IconContent("SceneViewOrtho", "|Modify the influence normal volume. (SHIFT+3)") }, |
|||
{ ToolBar.CapturePosition, EditorGUIUtility.IconContent("MoveTool", "|Change the Offset of the shape.") } |
|||
}); |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 43443fcbe23ff044eb73250a6d34cedd |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using UnityEditor.AnimatedValues; |
|||
using UnityEngine.Events; |
|||
using UnityEngine.Experimental.Rendering.HDPipeline; |
|||
using UnityEngine.Rendering; |
|||
|
|||
namespace UnityEditor.Experimental.Rendering.HDPipeline |
|||
{ |
|||
abstract partial class HDProbeUI : BaseUI<SerializedHDProbe> |
|||
{ |
|||
const int k_AnimBoolSingleFieldCount = 6; |
|||
static readonly int k_ReflectionProbeModeCount = Enum.GetValues(typeof(ReflectionProbeMode)).Length; |
|||
static readonly int k_ReflectionInfluenceShapeCount = Enum.GetValues(typeof(InfluenceShape)).Length; |
|||
static readonly int k_AnimBoolTotal = k_ReflectionProbeModeCount + k_AnimBoolSingleFieldCount + k_ReflectionInfluenceShapeCount; |
|||
|
|||
public InfluenceVolumeUI influenceVolume = new InfluenceVolumeUI(); |
|||
public FrameSettingsUI frameSettings = new FrameSettingsUI(); |
|||
public ReflectionProxyVolumeComponentUI reflectionProxyVolume = new ReflectionProxyVolumeComponentUI(); |
|||
|
|||
public AnimBool isSectionExpandedInfluenceSettings { get { return m_AnimBools[k_ReflectionProbeModeCount]; } } |
|||
public AnimBool isSectionExpandedCaptureSettings { get { return m_AnimBools[k_ReflectionProbeModeCount + 1]; } } |
|||
|
|||
public AnimBool isSectionExpandedCaptureMirrorSettings { get { return m_AnimBools[k_ReflectionProbeModeCount + 2]; } } |
|||
public AnimBool isSectionExpandedCaptureStaticSettings { get { return m_AnimBools[k_ReflectionProbeModeCount + 3]; } } |
|||
public AnimBool isSectionExpendedProxyVolume { get { return m_AnimBools[k_ReflectionProbeModeCount + 4]; } } |
|||
public AnimBool isSectionExpendedAdditionalSettings { get { return m_AnimBools[k_ReflectionProbeModeCount + 5]; } } |
|||
|
|||
public bool showCaptureHandles { get; set; } |
|||
|
|||
internal static HDProbeUI CreateFor(HDProbeEditor o) |
|||
{ |
|||
if (o is PlanarReflectionProbeEditor) |
|||
return new PlanarReflectionProbeUI(); |
|||
else |
|||
return new HDReflectionProbeUI(); |
|||
} |
|||
internal static HDProbeUI CreateFor(HDProbe p) |
|||
{ |
|||
if (p is PlanarReflectionProbe) |
|||
return new PlanarReflectionProbeUI(); |
|||
else |
|||
return new HDReflectionProbeUI(); |
|||
} |
|||
|
|||
public HDProbeUI() |
|||
: base(k_AnimBoolTotal) |
|||
{ |
|||
isSectionExpandedInfluenceSettings.value = true; |
|||
isSectionExpandedCaptureSettings.value = true; |
|||
isSectionExpendedProxyVolume.value = true; |
|||
isSectionExpendedAdditionalSettings.value = false; |
|||
} |
|||
|
|||
public AnimBool IsSectionExpandedReflectionProbeMode(ReflectionProbeMode mode) |
|||
{ |
|||
return m_AnimBools[(int)mode]; |
|||
} |
|||
|
|||
public void SetModeTarget(int value) |
|||
{ |
|||
for (var i = 0; i < k_ReflectionProbeModeCount; i++) |
|||
GetReflectionProbeModeBool(i).target = i == value; |
|||
} |
|||
|
|||
AnimBool GetReflectionProbeModeBool(int i) |
|||
{ |
|||
return m_AnimBools[i]; |
|||
} |
|||
|
|||
public override void Reset(SerializedHDProbe data, UnityAction repaint) |
|||
{ |
|||
frameSettings.Reset(data.frameSettings, repaint); |
|||
influenceVolume.Reset(data.influenceVolume, repaint); |
|||
base.Reset(data, repaint); |
|||
} |
|||
|
|||
public override void Update() |
|||
{ |
|||
for (var i = 0; i < k_ReflectionProbeModeCount; i++) |
|||
m_AnimBools[i].target = i == data.mode.intValue; |
|||
|
|||
SetModeTarget(data.mode.hasMultipleDifferentValues ? -1 : data.mode.intValue); |
|||
influenceVolume.SetIsSectionExpanded_Shape(data.influenceVolume.shape.hasMultipleDifferentValues ? -1 : data.influenceVolume.shape.intValue); |
|||
|
|||
frameSettings.Update(); |
|||
influenceVolume.Update(); |
|||
base.Update(); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: f23cf1efede7335468bfa23bd1838cd2 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using UnityEngine.Experimental.Rendering.HDPipeline; |
|||
|
|||
namespace UnityEditor.Experimental.Rendering.HDPipeline |
|||
{ |
|||
internal abstract class SerializedHDProbe |
|||
{ |
|||
internal SerializedObject serializedObject; |
|||
|
|||
internal SerializedProperty proxyVolumeReference; |
|||
internal SerializedProperty infiniteProjection; |
|||
|
|||
internal SerializedInfluenceVolume influenceVolume; |
|||
|
|||
internal SerializedFrameSettings frameSettings; |
|||
|
|||
internal SerializedProperty weight; |
|||
internal SerializedProperty multiplier; |
|||
internal SerializedProperty mode; |
|||
internal SerializedProperty refreshMode; |
|||
|
|||
internal SerializedProperty resolution; |
|||
internal SerializedProperty shadowDistance; |
|||
internal SerializedProperty cullingMask; |
|||
internal SerializedProperty useOcclusionCulling; |
|||
internal SerializedProperty nearClip; |
|||
internal SerializedProperty farClip; |
|||
|
|||
internal HDProbe target { get { return serializedObject.targetObject as HDProbe; } } |
|||
|
|||
internal SerializedHDProbe(SerializedObject serializedObject) |
|||
{ |
|||
this.serializedObject = serializedObject; |
|||
|
|||
proxyVolumeReference = serializedObject.Find((HDProbe p) => p.proxyVolume); |
|||
influenceVolume = new SerializedInfluenceVolume(serializedObject.Find((HDProbe p) => p.influenceVolume)); |
|||
infiniteProjection = serializedObject.Find((HDProbe p) => p.infiniteProjection); |
|||
|
|||
frameSettings = new SerializedFrameSettings(serializedObject.Find((HDProbe p) => p.frameSettings)); |
|||
|
|||
weight = serializedObject.Find((HDProbe p) => p.weight); |
|||
multiplier = serializedObject.Find((HDProbe p) => p.multiplier); |
|||
mode = serializedObject.Find((HDProbe p) => p.mode); |
|||
refreshMode = serializedObject.Find((HDProbe p) => p.refreshMode); |
|||
} |
|||
|
|||
internal virtual void Update() |
|||
{ |
|||
serializedObject.Update(); |
|||
//InfluenceVolume does not have Update. Add it here if it have in the future.
|
|||
} |
|||
|
|||
internal virtual void Apply() |
|||
{ |
|||
serializedObject.ApplyModifiedProperties(); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: fe06aab2f0da27148b61819e1ce565a1 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using UnityEngine; |
|||
using UnityEngine.Experimental.Rendering.HDPipeline; |
|||
|
|||
namespace UnityEditor.Experimental.Rendering.HDPipeline |
|||
{ |
|||
|
|||
partial class InfluenceVolumeUI |
|||
{ |
|||
static readonly Color k_GizmoThemeColorBase = new Color(255f / 255f, 229f / 255f, 148f / 255f, 80f / 255f); |
|||
static readonly Color k_GizmoThemeColorBaseFace = new Color(255f / 255f, 229f / 255f, 148f / 255f, 45f / 255f); |
|||
static readonly Color k_GizmoThemeColorInfluence = new Color(83f / 255f, 255f / 255f, 95f / 255f, 75f / 255f); |
|||
static readonly Color k_GizmoThemeColorInfluenceFace = new Color(83f / 255f, 255f / 255f, 95f / 255f, 17f / 255f); |
|||
static readonly Color k_GizmoThemeColorInfluenceNormal = new Color(0f / 255f, 229f / 255f, 255f / 255f, 80f / 255f); |
|||
static readonly Color k_GizmoThemeColorInfluenceNormalFace = new Color(0f / 255f, 229f / 255f, 255f / 255f, 36f / 255f); |
|||
static readonly Color k_GizmoThemeColorProjection = new Color(0x00 / 255f, 0xE5 / 255f, 0xFF / 255f, 0x20 / 255f); |
|||
static readonly Color k_GizmoThemeColorProjectionFace = new Color(0x00 / 255f, 0xE5 / 255f, 0xFF / 255f, 0x20 / 255f); |
|||
static readonly Color k_GizmoThemeColorDisabled = new Color(0x99 / 255f, 0x89 / 255f, 0x59 / 255f, 0x10 / 255f); |
|||
static readonly Color k_GizmoThemeColorDisabledFace = new Color(0x99 / 255f, 0x89 / 255f, 0x59 / 255f, 0x10 / 255f); |
|||
|
|||
static readonly GUIContent shapeContent = CoreEditorUtils.GetContent("Shape"); |
|||
static readonly GUIContent boxSizeContent = 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."); |
|||
static readonly GUIContent offsetContent = CoreEditorUtils.GetContent("Offset|The center of the InfluenceVolume in which the reflections will be applied to objects. The value is relative to the position of the Game Object."); |
|||
static readonly GUIContent blendDistanceContent = CoreEditorUtils.GetContent("Blend Distance|Area around the probe where it is blended with other probes. Only used in deferred probes."); |
|||
static readonly GUIContent blendNormalDistanceContent = CoreEditorUtils.GetContent("Blend Normal Distance|Area around the probe where the normals influence the probe. Only used in deferred probes."); |
|||
static readonly GUIContent faceFadeContent = CoreEditorUtils.GetContent("Face fade|Fade faces of the cubemap."); |
|||
|
|||
static readonly GUIContent radiusContent = CoreEditorUtils.GetContent("Radius"); |
|||
|
|||
static readonly GUIContent normalModeContent = CoreEditorUtils.GetContent("Normal|Normal parameters mode (only change for box shape)."); |
|||
static readonly GUIContent advancedModeContent = CoreEditorUtils.GetContent("Advanced|Advanced parameters mode (only change for box shape)."); |
|||
|
|||
static readonly string influenceVolumeHeader = "Influence Volume"; |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 28a19c3a1179dbd4698bf2618c4c5fb4 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: e389a5db9b96c2a4ba5f60f6a402d6f4 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using UnityEditorInternal; |
|||
using UnityEngine; |
|||
using UnityEngine.Experimental.Rendering.HDPipeline; |
|||
using UnityEngine.Rendering; |
|||
|
|||
namespace UnityEditor.Experimental.Rendering.HDPipeline |
|||
{ |
|||
using _ = CoreEditorUtils; |
|||
using CED = CoreEditorDrawer<PlanarReflectionProbeUI, SerializedPlanarReflectionProbe>; |
|||
|
|||
partial class PlanarReflectionProbeUI |
|||
{ |
|||
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 SectionProbeModeBakedSettings = CED.noop; |
|||
public static readonly CED.IDrawer SectionProbeModeCustomSettings = CED.Action(Drawer_SectionProbeModeCustomSettings); |
|||
public static readonly CED.IDrawer SectionProbeModeRealtimeSettings = CED.Action(Drawer_SectionProbeModeRealtimeSettings); |
|||
public static readonly CED.IDrawer SectionBakeButton = CED.Action(Drawer_SectionBakeButton); |
|||
|
|||
public static readonly CED.IDrawer SectionFoldoutAdditionalSettings = CED.FoldoutGroup( |
|||
"Artistic Settings", |
|||
(s, d, o) => s.isSectionExpendedAdditionalSettings, |
|||
FoldoutOption.Indent, |
|||
CED.Action(Drawer_SectionInfluenceSettings) |
|||
); |
|||
|
|||
public static readonly CED.IDrawer SectionFoldoutCaptureSettings; |
|||
|
|||
public static readonly CED.IDrawer SectionCaptureMirrorSettings = CED.Action(Drawer_SectionCaptureMirror); |
|||
public static readonly CED.IDrawer SectionCaptureStaticSettings = CED.Action(Drawer_SectionCaptureStatic); |
|||
|
|||
static PlanarReflectionProbeUI() |
|||
{ |
|||
SectionFoldoutCaptureSettings = CED.FoldoutGroup( |
|||
"Capture Settings", |
|||
(s, d, o) => s.isSectionExpandedCaptureSettings, |
|||
FoldoutOption.Indent, |
|||
CED.Action(Drawer_SectionCaptureSettings), |
|||
CED.FadeGroup( |
|||
(s, d, o, i) => |
|||
{ |
|||
switch (i) |
|||
{ |
|||
default: |
|||
case 0: return s.isSectionExpandedCaptureMirrorSettings; |
|||
case 1: return s.isSectionExpandedCaptureStaticSettings; |
|||
} |
|||
}, |
|||
FadeOption.None, |
|||
SectionCaptureMirrorSettings, |
|||
SectionCaptureStaticSettings) |
|||
); |
|||
|
|||
SectionProbeModeSettings = CED.Group( |
|||
CED.Action(Drawer_FieldCaptureType), |
|||
CED.FadeGroup( |
|||
(s, d, o, i) => s.IsSectionExpandedReflectionProbeMode((ReflectionProbeMode)i), |
|||
FadeOption.Indent, |
|||
SectionProbeModeBakedSettings, |
|||
SectionProbeModeRealtimeSettings, |
|||
SectionProbeModeCustomSettings |
|||
) |
|||
); |
|||
|
|||
Inspector = CED.Group( |
|||
CED.Action(Drawer_Toolbar), |
|||
CED.space, |
|||
ProxyVolumeSettings, |
|||
CED.Select( |
|||
(s, d, o) => s.influenceVolume, |
|||
(s, d, o) => d.influenceVolume, |
|||
InfluenceVolumeUI.SectionFoldoutShapePlanar |
|||
), |
|||
CED.Action(Drawer_DifferentShapeError), |
|||
SectionFoldoutCaptureSettings, |
|||
SectionFoldoutAdditionalSettings, |
|||
CED.Select( |
|||
(s, d, o) => s.frameSettings, |
|||
(s, d, o) => d.frameSettings, |
|||
FrameSettingsUI.Inspector |
|||
), |
|||
CED.space, |
|||
CED.Action(Drawer_SectionBakeButton) |
|||
); |
|||
} |
|||
|
|||
const EditMode.SceneViewEditMode EditBaseShape = EditMode.SceneViewEditMode.ReflectionProbeBox; |
|||
const EditMode.SceneViewEditMode EditInfluenceShape = EditMode.SceneViewEditMode.GridBox; |
|||
const EditMode.SceneViewEditMode EditInfluenceNormalShape = EditMode.SceneViewEditMode.Collider; |
|||
const EditMode.SceneViewEditMode EditCenter = EditMode.SceneViewEditMode.ReflectionProbeOrigin; |
|||
const EditMode.SceneViewEditMode EditMirrorPosition = EditMode.SceneViewEditMode.GridMove; |
|||
const EditMode.SceneViewEditMode EditMirrorRotation = EditMode.SceneViewEditMode.GridSelect; |
|||
|
|||
static void Drawer_SectionCaptureStatic(PlanarReflectionProbeUI s, SerializedPlanarReflectionProbe d, Editor o) |
|||
{ |
|||
EditorGUILayout.PropertyField(d.captureLocalPosition, _.GetContent("Capture Local Position")); |
|||
|
|||
_.DrawMultipleFields( |
|||
"Clipping Planes", |
|||
new[] { d.captureNearPlane, d.captureFarPlane }, |
|||
new[] { _.GetContent("Near|The closest point relative to the camera that drawing will occur."), _.GetContent("Far|The furthest point relative to the camera that drawing will occur.\n") }); |
|||
} |
|||
|
|||
static void Drawer_SectionCaptureMirror(PlanarReflectionProbeUI s, SerializedPlanarReflectionProbe d, Editor o) |
|||
{ |
|||
// EditorGUILayout.PropertyField(d.captureMirrorPlaneLocalPosition, _.GetContent("Plane Position"));
|
|||
// EditorGUILayout.PropertyField(d.captureMirrorPlaneLocalNormal, _.GetContent("Plane Normal"));
|
|||
} |
|||
|
|||
static void Drawer_DifferentShapeError(PlanarReflectionProbeUI s, SerializedPlanarReflectionProbe d, Editor o) |
|||
{ |
|||
var proxy = d.proxyVolumeReference.objectReferenceValue as ReflectionProxyVolumeComponent; |
|||
if (proxy != null && (int)proxy.proxyVolume.shape != d.influenceVolume.shape.enumValueIndex) |
|||
{ |
|||
EditorGUILayout.HelpBox( |
|||
"Proxy volume and influence volume have different shape types, this is not supported.", |
|||
MessageType.Error, |
|||
true |
|||
); |
|||
} |
|||
} |
|||
|
|||
static void Drawer_SectionCaptureSettings(PlanarReflectionProbeUI s, SerializedPlanarReflectionProbe d, Editor o) |
|||
{ |
|||
var hdrp = GraphicsSettings.renderPipelineAsset as HDRenderPipelineAsset; |
|||
GUI.enabled = false; |
|||
EditorGUILayout.LabelField( |
|||
_.GetContent("Probe Texture Size (Set By HDRP)"), |
|||
_.GetContent(hdrp.renderPipelineSettings.lightLoopSettings.planarReflectionTextureSize.ToString()), |
|||
EditorStyles.label); |
|||
EditorGUILayout.Toggle( |
|||
_.GetContent("Probe Compression (Set By HDRP)"), |
|||
hdrp.renderPipelineSettings.lightLoopSettings.planarReflectionCacheCompressed); |
|||
GUI.enabled = true; |
|||
|
|||
EditorGUILayout.PropertyField(d.overrideFieldOfView, _.GetContent("Override FOV")); |
|||
if (d.overrideFieldOfView.boolValue) |
|||
{ |
|||
++EditorGUI.indentLevel; |
|||
EditorGUILayout.PropertyField(d.fieldOfViewOverride, _.GetContent("Field Of View")); |
|||
--EditorGUI.indentLevel; |
|||
} |
|||
} |
|||
|
|||
static void Drawer_SectionProbeModeCustomSettings(PlanarReflectionProbeUI s, SerializedPlanarReflectionProbe d, Editor o) |
|||
{ |
|||
d.customTexture.objectReferenceValue = EditorGUILayout.ObjectField(_.GetContent("Capture"), d.customTexture.objectReferenceValue, typeof(Texture), false); |
|||
var texture = d.customTexture.objectReferenceValue as Texture; |
|||
if (texture != null && texture.dimension != TextureDimension.Tex2D) |
|||
EditorGUILayout.HelpBox("Provided Texture is not a 2D Texture, it will be ignored", MessageType.Warning); |
|||
} |
|||
|
|||
static void Drawer_SectionBakeButton(PlanarReflectionProbeUI s, SerializedPlanarReflectionProbe d, Editor o) |
|||
{ |
|||
EditorReflectionSystemGUI.DrawBakeButton((ReflectionProbeMode)d.mode.intValue, d.target); |
|||
} |
|||
|
|||
static void Drawer_SectionProbeModeRealtimeSettings(PlanarReflectionProbeUI s, SerializedPlanarReflectionProbe d, Editor o) |
|||
{ |
|||
GUI.enabled = false; |
|||
EditorGUILayout.PropertyField(d.refreshMode, _.GetContent("Refresh Mode")); |
|||
EditorGUILayout.PropertyField(d.capturePositionMode, _.GetContent("Capture Position Mode")); |
|||
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.shape != d.influenceVolume.shape.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")); |
|||
|
|||
|
|||
EditorGUI.BeginChangeCheck(); |
|||
EditorGUILayout.PropertyField(d.multiplier, _.GetContent("Multiplier")); |
|||
if (EditorGUI.EndChangeCheck()) |
|||
d.multiplier.floatValue = Mathf.Max(0.0f, d.multiplier.floatValue); |
|||
} |
|||
|
|||
static void Drawer_FieldCaptureType(PlanarReflectionProbeUI s, SerializedPlanarReflectionProbe d, Editor o) |
|||
{ |
|||
GUI.enabled = false; |
|||
EditorGUILayout.PropertyField(d.mode, _.GetContent("Type")); |
|||
GUI.enabled = true; |
|||
} |
|||
|
|||
static readonly EditMode.SceneViewEditMode[] k_Toolbar_SceneViewEditModes = |
|||
{ |
|||
EditBaseShape, |
|||
EditInfluenceShape, |
|||
EditInfluenceNormalShape, |
|||
//EditCenter
|
|||
}; |
|||
|
|||
static readonly EditMode.SceneViewEditMode[] k_Toolbar_Static_SceneViewEditModes = |
|||
{ |
|||
//EditCenter //offset have no meanings with planar
|
|||
}; |
|||
static readonly EditMode.SceneViewEditMode[] k_Toolbar_Mirror_SceneViewEditModes = |
|||
{ |
|||
//EditMirrorPosition, //offset have no meanings with planar
|
|||
EditMirrorRotation |
|||
}; |
|||
static GUIContent[] s_Toolbar_Contents = null; |
|||
static GUIContent[] toolbar_Contents |
|||
{ |
|||
get |
|||
{ |
|||
return s_Toolbar_Contents ?? (s_Toolbar_Contents = new[] |
|||
{ |
|||
EditorGUIUtility.IconContent("EditCollider", "|Modify the base shape. (SHIFT+1)"), |
|||
EditorGUIUtility.IconContent("PreMatCube", "|Modify the influence volume. (SHIFT+2)"), |
|||
EditorGUIUtility.IconContent("SceneViewOrtho", "|Modify the influence normal volume. (SHIFT+3)"), |
|||
}); |
|||
} |
|||
} |
|||
|
|||
static GUIContent[] s_Toolbar_Static_Contents = null; |
|||
static GUIContent[] toolbar_Static_Contents |
|||
{ |
|||
get |
|||
{ |
|||
return s_Toolbar_Static_Contents ?? (s_Toolbar_Static_Contents = new GUIContent[] |
|||
{ |
|||
//EditorGUIUtility.IconContent("MoveTool", "|Move the capture position.") //offset have no meanings with planar
|
|||
}); |
|||
} |
|||
} |
|||
|
|||
static GUIContent[] s_Toolbar_Mirror_Contents = null; |
|||
static GUIContent[] toolbar_Mirror_Contents |
|||
{ |
|||
get |
|||
{ |
|||
return s_Toolbar_Mirror_Contents ?? (s_Toolbar_Mirror_Contents = new[] |
|||
{ |
|||
//EditorGUIUtility.IconContent("MoveTool", "|Move the mirror plane."), //offset have no meanings with planar
|
|||
EditorGUIUtility.IconContent("RotateTool", "|Rotate the mirror plane.") |
|||
}); |
|||
} |
|||
} |
|||
|
|||
static void Drawer_Toolbar(PlanarReflectionProbeUI s, SerializedPlanarReflectionProbe d, Editor o) |
|||
{ |
|||
GUILayout.BeginHorizontal(); |
|||
GUILayout.FlexibleSpace(); |
|||
GUI.changed = false; |
|||
|
|||
EditMode.DoInspectorToolbar(k_Toolbar_SceneViewEditModes, toolbar_Contents, GetBoundsGetter(o), o); |
|||
|
|||
if (d.isMirrored) |
|||
EditMode.DoInspectorToolbar(k_Toolbar_Mirror_SceneViewEditModes, toolbar_Mirror_Contents, GetBoundsGetter(o), o); |
|||
else |
|||
EditMode.DoInspectorToolbar(k_Toolbar_Static_SceneViewEditModes, toolbar_Static_Contents, GetBoundsGetter(o), o); |
|||
|
|||
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) |
|||
{ |
|||
return () => |
|||
{ |
|||
var bounds = new Bounds(); |
|||
foreach (Component targetObject in o.targets) |
|||
{ |
|||
var rp = targetObject.transform; |
|||
var b = rp.position; |
|||
bounds.Encapsulate(b); |
|||
} |
|||
return bounds; |
|||
}; |
|||
} |
|||
} |
|||
} |
|
|||
using UnityEditor.IMGUI.Controls; |
|||
using UnityEditorInternal; |
|||
using UnityEngine; |
|||
using UnityEngine.Experimental.Rendering; |
|||
using UnityEngine.Experimental.Rendering.HDPipeline; |
|||
using UnityEditor.Experimental.Rendering.HDPipeline; |
|||
|
|||
namespace UnityEditor.Experimental.Rendering.HDPipeline |
|||
{ |
|||
partial class HDReflectionProbeEditor |
|||
{ |
|||
enum InfluenceType |
|||
{ |
|||
Standard, |
|||
Normal |
|||
} |
|||
|
|||
void OnSceneGUI() |
|||
{ |
|||
var s = m_UIState; |
|||
var p = m_SerializedHdReflectionProbe; |
|||
var o = this; |
|||
|
|||
BakeRealtimeProbeIfPositionChanged(s, p, o); |
|||
|
|||
HDReflectionProbeUI.DoShortcutKey(p, o); |
|||
|
|||
if (!s.sceneViewEditing) |
|||
return; |
|||
|
|||
var mat = Matrix4x4.TRS(p.target.transform.position, p.target.transform.rotation, Vector3.one); |
|||
|
|||
EditorGUI.BeginChangeCheck(); |
|||
|
|||
switch (EditMode.editMode) |
|||
{ |
|||
// Influence editing
|
|||
case EditMode.SceneViewEditMode.ReflectionProbeBox: |
|||
InfluenceVolumeUI.DrawHandles_EditBase(s.influenceVolume, p.targetData.influenceVolume, o, mat, p.targetData); |
|||
break; |
|||
// Influence fade editing
|
|||
case EditMode.SceneViewEditMode.GridBox: |
|||
InfluenceVolumeUI.DrawHandles_EditInfluence(s.influenceVolume, p.targetData.influenceVolume, o, mat, p.targetData); |
|||
break; |
|||
// Influence normal fade editing
|
|||
case EditMode.SceneViewEditMode.Collider: |
|||
InfluenceVolumeUI.DrawHandles_EditInfluenceNormal(s.influenceVolume, p.targetData.influenceVolume, o, mat, p.targetData); |
|||
break; |
|||
// Origin editing
|
|||
case EditMode.SceneViewEditMode.ReflectionProbeOrigin: |
|||
Handle_OriginEditing(s, p, o); |
|||
break; |
|||
} |
|||
|
|||
if (EditorGUI.EndChangeCheck()) |
|||
Repaint(); |
|||
} |
|||
|
|||
static void Handle_OriginEditing(HDReflectionProbeUI s, SerializedHDReflectionProbe sp, Editor o) |
|||
{ |
|||
var p = (ReflectionProbe)sp.so.targetObject; |
|||
var transformPosition = p.transform.position; |
|||
var size = p.size; |
|||
|
|||
EditorGUI.BeginChangeCheck(); |
|||
var newPostion = Handles.PositionHandle(transformPosition, HDReflectionProbeEditorUtility.GetLocalSpaceRotation(p)); |
|||
|
|||
var changed = EditorGUI.EndChangeCheck(); |
|||
|
|||
if (changed || s.oldLocalSpace != HDReflectionProbeEditorUtility.GetLocalSpace(p)) |
|||
{ |
|||
var localNewPosition = s.oldLocalSpace.inverse.MultiplyPoint3x4(newPostion); |
|||
|
|||
var b = new Bounds(p.center, size); |
|||
localNewPosition = b.ClosestPoint(localNewPosition); |
|||
|
|||
Undo.RecordObject(p.transform, "Modified Reflection Probe Origin"); |
|||
p.transform.position = s.oldLocalSpace.MultiplyPoint3x4(localNewPosition); |
|||
|
|||
Undo.RecordObject(p, "Modified Reflection Probe Origin"); |
|||
p.center = HDReflectionProbeEditorUtility.GetLocalSpace(p).inverse.MultiplyPoint3x4(s.oldLocalSpace.MultiplyPoint3x4(p.center)); |
|||
|
|||
EditorUtility.SetDirty(p); |
|||
|
|||
s.UpdateOldLocalSpace(p); |
|||
} |
|||
} |
|||
} |
|||
} |
撰写
预览
正在加载...
取消
保存
Reference in new issue