浏览代码

Merge pull request #1645 from Unity-Technologies/xrsettings

UI cleanup for XRGraphicsConfig renderScale/viewportScale
/main
GitHub 6 年前
当前提交
162e4cee
共有 5 个文件被更改,包括 6 次插入14 次删除
  1. 4
      com.unity.render-pipelines.core/CoreRP/Common/XRGraphicsConfig.cs
  2. 9
      com.unity.render-pipelines.core/CoreRP/Editor/XRGraphicsConfigDrawer.cs
  3. 1
      com.unity.render-pipelines.lightweight/LWRP/Data/LightweightPipelineAsset.cs
  4. 4
      com.unity.render-pipelines.lightweight/LWRP/Editor/LightweightPipelineAssetEditor.cs
  5. 2
      com.unity.render-pipelines.lightweight/LWRP/LightweightPipeline.cs

4
com.unity.render-pipelines.core/CoreRP/Common/XRGraphicsConfig.cs


namespace UnityEngine.Experimental.Rendering
{
[Serializable]
public struct XRGraphicsConfig
public class XRGraphicsConfig
{ // XRGConfig stores the desired XR settings for a given SRP asset.
public float renderScale;

return false;
#endif
}
}
}
public static RenderTextureDescriptor eyeTextureDesc
{

9
com.unity.render-pipelines.core/CoreRP/Editor/XRGraphicsConfigDrawer.cs


[CustomPropertyDrawer(typeof(XRGraphicsConfig))]
public class XRGraphicsConfigDrawer : PropertyDrawer
{
private float k_MinRenderScale = 0.01f;
private float k_MaxRenderScale = 4.0f;
public static GUIContent XREnabledLabel = new GUIContent("Enable XR", "Enables stereo rendering");
public static GUIContent renderScaleLabel = new GUIContent("Render Scale", "Scales (and reallocates) the camera render target allowing the game to render at a resolution different than native resolution. Can't be modified in play mode.");
public static GUIContent viewportScaleLabel = new GUIContent("Viewport Scale", "Scales the section of the render target being rendered. Use for dynamic resolution adjustments.");
public static GUIContent stereoRenderModeLabel = new GUIContent("Stereo Rendering Mode", "Use Player Settings to select between supported stereo rendering paths for current VR device.");
public static GUIContent showDeviceViewLabel = new GUIContent("Show Device View", "If possible, mirror the render target of the VR device to the main display.");
public static GUIContent gameViewRenderModeLabel = new GUIContent("Game View Render Mode", "Select how to reflect stereo display to game view");

// Draw the property inside the given rect
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
var drawRenderScale = property.FindPropertyRelative("renderScale");
var drawViewportScale = property.FindPropertyRelative("viewportScale");
var drawShowDeviceView = property.FindPropertyRelative("showDeviceView");
var drawGameViewRenderMode = property.FindPropertyRelative("gameViewRenderMode");
var drawUseOcclusionMesh = property.FindPropertyRelative("useOcclusionMesh");

EditorGUILayout.LabelField(Styles.XRSettingsLabel, EditorStyles.boldLabel);
EditorGUI.indentLevel++;
drawRenderScale.floatValue = EditorGUILayout.Slider(Styles.renderScaleLabel, drawRenderScale.floatValue, k_MinRenderScale, k_MaxRenderScale);
drawViewportScale.floatValue = EditorGUILayout.Slider(Styles.viewportScaleLabel, drawViewportScale.floatValue, k_MinRenderScale, k_MaxRenderScale);
EditorGUILayout.PropertyField(drawUseOcclusionMesh, Styles.useOcclusionMeshLabel);
EditorGUILayout.PropertyField(drawOcclusionMaskScale, Styles.occlusionScaleLabel);
EditorGUILayout.PropertyField(drawShowDeviceView, Styles.showDeviceViewLabel);

1
com.unity.render-pipelines.lightweight/LWRP/Data/LightweightPipelineAsset.cs


public XRGraphicsConfig savedXRGraphicsConfig
{
get { return m_SavedXRConfig; }
set { m_SavedXRConfig = value; }
}
public void OnBeforeSerialize()

4
com.unity.render-pipelines.lightweight/LWRP/Editor/LightweightPipelineAssetEditor.cs


public static GUIContent localShadowLabel = new GUIContent("Local Shadows");
public static GUIContent capabilitiesLabel = new GUIContent("Capabilities");
public static GUIContent renderScaleLabel = new GUIContent("Render Scale", "Scales the camera render target allowing the game to render at a resolution different than native resolution. UI is always rendered at native resolution. When in VR mode, uses value set in XRGraphicsConfig instead.");
public static GUIContent renderScaleLabel = new GUIContent("Render Scale", "Scales the camera render target allowing the game to render at a resolution different than native resolution. UI is always rendered at native resolution.");
public static GUIContent maxPixelLightsLabel = new GUIContent("Pixel Lights",
"Controls the amount of pixel lights that run in fragment light loop. Lights are sorted and culled per-object.");

{
EditorGUILayout.LabelField(Styles.generalSettingsLabel, EditorStyles.boldLabel);
EditorGUI.indentLevel++;
EditorGUI.BeginDisabledGroup(XRGraphicsConfig.tryEnable); // Begin XR-overridden values
EditorGUI.EndDisabledGroup(); // End XR-overridden values
m_MaxPixelLights.intValue = EditorGUILayout.IntSlider(Styles.maxPixelLightsLabel, m_MaxPixelLights.intValue, 0, k_MaxSupportedPixelLights);
EditorGUILayout.Space();

2
com.unity.render-pipelines.lightweight/LWRP/LightweightPipeline.cs


Debug.LogWarning("Nested camera rendering is forbidden. If you are calling camera.Render inside OnWillRenderObject callback, use BeginCameraRender callback instead.");
return;
}
pipelineAsset.savedXRGraphicsConfig.renderScale = pipelineAsset.renderScale;
pipelineAsset.savedXRGraphicsConfig.viewportScale = 1.0f; // Placeholder until viewportScale is all hooked up
// Apply any changes to XRGConfig prior to this point
pipelineAsset.savedXRGraphicsConfig.SetConfig();

正在加载...
取消
保存