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: //important: following will init the container for box. //This must be done before drawing the contained handles 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))) { EditorGUI.BeginChangeCheck(); var newCapturePosition = Handles.PositionHandle(probe.transform.position, probe.transform.rotation); if (EditorGUI.EndChangeCheck()) { Vector3 newOffset = Quaternion.Inverse(probe.transform.rotation) * (newCapturePosition - probe.transform.position); Undo.RecordObjects(new Object[] { probe, probe.transform }, "Translate Influence Position"); Vector3 delta = newCapturePosition - probe.transform.position; Matrix4x4 oldLocalToWorld = Matrix4x4.TRS(probe.transform.position, probe.transform.rotation, Vector3.one); //call modification to legacy ReflectionProbe probe.influenceVolume.offset = newOffset; probe.transform.position = newCapturePosition; d.influenceVolume.offset.vector3Value -= oldLocalToWorld.inverse.MultiplyVector(delta); d.influenceVolume.Apply(); } } break; } } }
protected static void Drawer_SectionCustomSettings(HDProbeUI s, SerializedHDProbe d, Editor o) { var hdPipeline = RenderPipelineManager.currentPipeline as HDRenderPipeline; using (new EditorGUI.DisabledScope(!hdPipeline.asset.renderPipelineSettings.supportLightLayers)) { d.lightLayers.intValue = Convert.ToInt32(EditorGUILayout.EnumFlagsField(lightLayersContent, (LightLayerEnum)d.lightLayers.intValue)); } 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); } }
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]; } }
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; } } }
internal static void DrawGizmos(PlanarReflectionProbe d, GizmoType gizmoType) { HDProbeUI.DrawGizmos(d, gizmoType); HDProbeUI s; if (!HDProbeEditor.TryGetUIStateFor(d, out s)) { return; } if (s.showCaptureHandles || EditMode.editMode == EditCenter) { DrawGizmos_CaptureFrustrum(d); } if (d.useMirrorPlane) { DrawGizmos_CaptureMirror(d); } }
internal static void DrawHandles(PlanarReflectionProbeUI s, SerializedPlanarReflectionProbe d, Editor o) { PlanarReflectionProbe probe = d.target; HDProbeUI.DrawHandles(s, d, o); if (probe.useMirrorPlane) { var m = Handles.matrix; var mat = Matrix4x4.TRS(probe.transform.position, probe.transform.rotation, Vector3.one * 1.5f); using (new Handles.DrawingScope(k_GizmoMirrorPlaneCamera, mat)) { Handles.ArrowHandleCap( 0, probe.captureMirrorPlaneLocalPosition, Quaternion.LookRotation(probe.captureMirrorPlaneLocalNormal), HandleUtility.GetHandleSize(probe.captureMirrorPlaneLocalPosition), Event.current.type ); } } }
static void Drawer_SectionShapeSphere(InfluenceVolumeUI s, SerializedInfluenceVolume d, Editor o, bool drawOffset, bool drawNormal) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.PropertyField(d.sphereRadius, radiusContent); HDProbeUI.Drawer_ToolBarButton(HDProbeUI.ToolBar.InfluenceShape, o, GUILayout.Width(28f), GUILayout.MinHeight(22f)); EditorGUILayout.EndHorizontal(); if (drawOffset) { Drawer_Offset(s, d, o); } EditorGUILayout.Space(); var maxBlendDistance = d.sphereRadius.floatValue; EditorGUILayout.BeginHorizontal(); EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(d.sphereBlendDistance, blendDistanceContent); if (EditorGUI.EndChangeCheck()) { d.sphereBlendDistance.floatValue = Mathf.Clamp(d.sphereBlendDistance.floatValue, 0, maxBlendDistance); } HDProbeUI.Drawer_ToolBarButton(HDProbeUI.ToolBar.Blend, o, GUILayout.ExpandHeight(true), GUILayout.Width(28f), GUILayout.MinHeight(22f), GUILayout.MaxHeight(EditorGUIUtility.singleLineHeight + 3)); EditorGUILayout.EndHorizontal(); if (drawNormal) { EditorGUILayout.BeginHorizontal(); EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(d.sphereBlendNormalDistance, blendNormalDistanceContent); if (EditorGUI.EndChangeCheck()) { d.sphereBlendNormalDistance.floatValue = Mathf.Clamp(d.sphereBlendNormalDistance.floatValue, 0, maxBlendDistance); } HDProbeUI.Drawer_ToolBarButton(HDProbeUI.ToolBar.NormalBlend, o, GUILayout.ExpandHeight(true), GUILayout.Width(28f), GUILayout.MinHeight(22f), GUILayout.MaxHeight(EditorGUIUtility.singleLineHeight + 3)); EditorGUILayout.EndHorizontal(); } }
protected static void Drawer_SectionCaptureSettings(HDProbeUI s, SerializedHDProbe d, Editor o) { 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; }
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 override void Draw(HDProbeUI s, SerializedHDProbe serialized, Editor owner) { PlanarReflectionProbeUI.Inspector.Draw(s, serialized, owner); }
static void Drawer_SectionShapeBox(InfluenceVolumeUI s, SerializedInfluenceVolume d, Editor o, bool drawOffset, bool drawNormal, bool drawFace) { bool advanced = d.editorAdvancedModeEnabled.boolValue; var maxFadeDistance = d.boxSize.vector3Value * 0.5f; var minFadeDistance = Vector3.zero; EditorGUILayout.BeginHorizontal(); EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(d.boxSize, boxSizeContent); if (EditorGUI.EndChangeCheck()) { Vector3 blendPositive = d.boxBlendDistancePositive.vector3Value; Vector3 blendNegative = d.boxBlendDistanceNegative.vector3Value; Vector3 blendNormalPositive = d.boxBlendNormalDistancePositive.vector3Value; Vector3 blendNormalNegative = d.boxBlendNormalDistanceNegative.vector3Value; Vector3 size = d.boxSize.vector3Value; for (int i = 0; i < 3; ++i) { size[i] = Mathf.Max(0f, size[i]); } d.boxSize.vector3Value = size; Vector3 halfSize = size * .5f; for (int i = 0; i < 3; ++i) { blendPositive[i] = Mathf.Clamp(blendPositive[i], 0f, halfSize[i]); blendNegative[i] = Mathf.Clamp(blendNegative[i], 0f, halfSize[i]); blendNormalPositive[i] = Mathf.Clamp(blendNormalPositive[i], 0f, halfSize[i]); blendNormalNegative[i] = Mathf.Clamp(blendNormalNegative[i], 0f, halfSize[i]); } d.boxBlendDistancePositive.vector3Value = blendPositive; d.boxBlendDistanceNegative.vector3Value = blendNegative; d.boxBlendNormalDistancePositive.vector3Value = blendNormalPositive; d.boxBlendNormalDistanceNegative.vector3Value = blendNormalNegative; if (d.editorAdvancedModeEnabled.boolValue) { d.editorAdvancedModeBlendDistancePositive.vector3Value = d.boxBlendDistancePositive.vector3Value; d.editorAdvancedModeBlendDistanceNegative.vector3Value = d.boxBlendDistanceNegative.vector3Value; d.editorAdvancedModeBlendNormalDistancePositive.vector3Value = d.boxBlendNormalDistancePositive.vector3Value; d.editorAdvancedModeBlendNormalDistanceNegative.vector3Value = d.boxBlendNormalDistanceNegative.vector3Value; } else { d.editorSimplifiedModeBlendDistance.floatValue = Mathf.Max(blendPositive.x, blendPositive.y, blendPositive.z, blendNegative.x, blendNegative.y, blendNegative.z); d.boxBlendDistancePositive.vector3Value = d.boxBlendDistanceNegative.vector3Value = Vector3.one * d.editorSimplifiedModeBlendDistance.floatValue; d.editorSimplifiedModeBlendNormalDistance.floatValue = Mathf.Max(blendNormalPositive.x, blendNormalPositive.y, blendNormalPositive.z, blendNormalNegative.x, blendNormalNegative.y, blendNormalNegative.z); d.boxBlendNormalDistancePositive.vector3Value = d.boxBlendNormalDistanceNegative.vector3Value = Vector3.one * d.editorSimplifiedModeBlendNormalDistance.floatValue; } } HDProbeUI.Drawer_ToolBarButton(HDProbeUI.ToolBar.InfluenceShape, o, GUILayout.Width(28f), GUILayout.MinHeight(22f)); EditorGUILayout.EndHorizontal(); if (drawOffset) { Drawer_Offset(s, d, o); } GUILayout.Space(EditorGUIUtility.standardVerticalSpacing); EditorGUILayout.BeginHorizontal(); Drawer_AdvancedBlendDistance(d, false, maxFadeDistance, blendDistanceContent); HDProbeUI.Drawer_ToolBarButton(HDProbeUI.ToolBar.Blend, o, GUILayout.ExpandHeight(true), GUILayout.Width(28f), GUILayout.MinHeight(22f), GUILayout.MaxHeight((advanced ? 2 : 1) * (EditorGUIUtility.singleLineHeight + 3))); EditorGUILayout.EndHorizontal(); GUILayout.Space(EditorGUIUtility.standardVerticalSpacing * 2f); if (drawNormal) { EditorGUILayout.BeginHorizontal(); Drawer_AdvancedBlendDistance(d, true, maxFadeDistance, blendNormalDistanceContent); HDProbeUI.Drawer_ToolBarButton(HDProbeUI.ToolBar.NormalBlend, o, GUILayout.ExpandHeight(true), GUILayout.Width(28f), GUILayout.MinHeight(22f), GUILayout.MaxHeight((advanced ? 2 : 1) * (EditorGUIUtility.singleLineHeight + 3))); EditorGUILayout.EndHorizontal(); GUILayout.Space(EditorGUIUtility.standardVerticalSpacing * 2f); } if (advanced && drawFace) { EditorGUILayout.BeginHorizontal(); Vector3 positive = d.editorAdvancedModeFaceFadePositive.vector3Value; Vector3 negative = d.editorAdvancedModeFaceFadeNegative.vector3Value; EditorGUI.BeginChangeCheck(); CoreEditorUtils.DrawVector6(faceFadeContent, ref positive, ref negative, Vector3.zero, Vector3.one, InfluenceVolumeUI.k_HandlesColor); if (EditorGUI.EndChangeCheck()) { d.boxSideFadePositive.vector3Value = d.editorAdvancedModeFaceFadePositive.vector3Value = positive; d.boxSideFadeNegative.vector3Value = d.editorAdvancedModeFaceFadeNegative.vector3Value = negative; } GUILayout.Space(28f + 9f); //add right margin for alignment EditorGUILayout.EndHorizontal(); GUILayout.Space(EditorGUIUtility.standardVerticalSpacing * 2f); } }
static void Drawer_SectionProbeModeRealtimeSettings(HDProbeUI s, SerializedHDProbe d, Editor o) { GUI.enabled = false; EditorGUILayout.PropertyField(d.refreshMode, _.GetContent("Refresh Mode")); GUI.enabled = true; }
static void Drawer_FieldCaptureType(HDProbeUI s, SerializedHDProbe d, Editor o) { GUI.enabled = false; EditorGUILayout.PropertyField(d.mode, fieldCaptureTypeContent); GUI.enabled = true; }
protected abstract void Draw(HDProbeUI s, SerializedHDProbe serialized, Editor owner);
internal static bool TryGetUIStateFor(HDProbe p, out HDProbeUI r) { return(s_StateMap.TryGetValue(p, out r)); }
public static void Draw( SerializedProbeSettings serialized, Editor owner, SerializedProbeSettingsOverride @override, ProbeSettingsOverride displayedFields, ProbeSettingsOverride overridableFields ) { const ProbeSettingsFields lighting = ProbeSettingsFields.lightingLightLayer | ProbeSettingsFields.lightingMultiplier | ProbeSettingsFields.lightingWeight; const ProbeSettingsFields proxy = ProbeSettingsFields.proxyCapturePositionProxySpace | ProbeSettingsFields.proxyCaptureRotationProxySpace | ProbeSettingsFields.proxyMirrorPositionProxySpace | ProbeSettingsFields.proxyMirrorRotationProxySpace | ProbeSettingsFields.proxyUseInfluenceVolumeAsProxyVolume; if (!(RenderPipelineManager.currentPipeline is HDRenderPipeline hd)) { return; } if ((displayedFields.probe & lighting) != 0) { GUI.enabled = hd.currentPlatformRenderPipelineSettings.supportLightLayers; PropertyFieldWithFlagToggleIfDisplayed(ProbeSettingsFields.lightingLightLayer, serialized.lightingLightLayer, EditorGUIUtility.TrTextContent("Light Layer", "Specifies the Light Layer the Reflection Probe uses to capture its view of the Scene. The Probe only uses Lights on the Light Layer you specify."), @override.probe, displayedFields.probe, overridableFields.probe); GUI.enabled = true; PropertyFieldWithFlagToggleIfDisplayed(ProbeSettingsFields.lightingMultiplier, serialized.lightingMultiplier, EditorGUIUtility.TrTextContent("Multiplier", "Sets the multiplier value that reflective Materials apply to the results from the Reflection Probe."), @override.probe, displayedFields.probe, overridableFields.probe); PropertyFieldWithFlagToggleIfDisplayed(ProbeSettingsFields.lightingWeight, serialized.lightingWeight, EditorGUIUtility.TrTextContent("Weight", "Sets the weight of this Reflection Probe. When multiple Probes both affect the same area of a reflective Material, the Material uses the Weight of each Probe to determine their contribution to the reflective effect."), @override.probe, displayedFields.probe, overridableFields.probe); EditorGUILayout.Space(); } if ((displayedFields.probe & proxy) != 0) { PropertyFieldWithFlagToggleIfDisplayed(ProbeSettingsFields.proxyUseInfluenceVolumeAsProxyVolume, serialized.proxyUseInfluenceVolumeAsProxyVolume, EditorGUIUtility.TrTextContent("Use Influence Volume As Proxy Volume", "When enabled, this Reflection Probe uses the boundaries of the Influence Volume as its Proxy Volume."), @override.probe, displayedFields.probe, overridableFields.probe); PropertyFieldWithFlagToggleIfDisplayed(ProbeSettingsFields.proxyCapturePositionProxySpace, serialized.proxyCapturePositionProxySpace, EditorGUIUtility.TrTextContent("Capture Position", "Sets the position, relative to the Transform Position, from which the Reflection Probe captures its surroundings."), @override.probe, displayedFields.probe, overridableFields.probe, (p, l) => { EditorGUILayout.PropertyField(p, l); HDProbeUI.Drawer_ToolBarButton(HDProbeUI.ToolBar.CapturePosition, owner, GUILayout.Width(28f), GUILayout.MinHeight(22f)); } ); PropertyFieldWithFlagToggleIfDisplayed(ProbeSettingsFields.proxyCaptureRotationProxySpace, serialized.proxyCaptureRotationProxySpace, EditorGUIUtility.TrTextContent("Capture Rotation", "Sets the rotation of the capture point relative to the Transform Rotation."), @override.probe, displayedFields.probe, overridableFields.probe); PropertyFieldWithFlagToggleIfDisplayed(ProbeSettingsFields.proxyMirrorPositionProxySpace, serialized.proxyMirrorPositionProxySpace, EditorGUIUtility.TrTextContent("Mirror Position", "Sets the position of the Planar Reflection Probe relative to the Transform Position."), @override.probe, displayedFields.probe, overridableFields.probe, (p, l) => { EditorGUILayout.PropertyField(p, l); HDProbeUI.Drawer_ToolBarButton(HDProbeUI.ToolBar.MirrorPosition, owner, GUILayout.Width(28f), GUILayout.MinHeight(22f)); } ); PropertyFieldWithFlagToggleIfDisplayed(ProbeSettingsFields.proxyMirrorRotationProxySpace, serialized.proxyMirrorRotationProxySpace, EditorGUIUtility.TrTextContent("Mirror Rotation", "Sets the rotation of the Planar Reflection Probe relative to the Transform Rotation."), @override.probe, displayedFields.probe, overridableFields.probe, (p, l) => { EditorGUILayout.PropertyField(p, l); HDProbeUI.Drawer_ToolBarButton(HDProbeUI.ToolBar.MirrorRotation, owner, GUILayout.Width(28f), GUILayout.MinHeight(22f)); } ); EditorGUILayout.Space(); } CameraSettingsUI.Draw(serialized.cameraSettings, owner, @override.camera, displayedFields.camera, overridableFields.camera); }
static void Drawer_ModeSettingsRealtime(HDProbeUI s, SerializedHDProbe p, Editor owner) { SerializedHDReflectionProbe probe = (SerializedHDReflectionProbe)p; //EditorGUILayout.PropertyField(p.refreshMode, CoreEditorUtils.GetContent("Refresh Mode|Controls how this probe refreshes in the Player")); //EditorGUILayout.PropertyField(probe.timeSlicingMode, CoreEditorUtils.GetContent("Time Slicing|If enabled this probe will update over several frames, to help reduce the impact on the frame rate")); }
protected override void Draw(HDProbeUI s, SerializedHDProbe serialized, Editor owner) { #pragma warning disable 612 //Draw HDReflectionProbeUI.Inspector.Draw(s, serialized, owner); #pragma warning restore 612 }