using UnityEngine; using UnityEngine.Rendering.Universal; namespace UnityEditor.Rendering.Universal { using CED = CoreEditorDrawer; static partial class UniversalRenderPipelineCameraUI { [URPHelpURL("camera-component-reference")] public enum Expandable { /// Projection Projection = 1 << 0, /// Physical Physical = 1 << 1, /// Output Output = 1 << 2, /// Orthographic Orthographic = 1 << 3, /// RenderLoop RenderLoop = 1 << 4, /// Rendering Rendering = 1 << 5, /// Environment Environment = 1 << 6, /// Stack Stack = 1 << 7, } public enum ExpandableAdditional { /// Rendering Rendering = 1 << 0, } static readonly ExpandedState k_ExpandedState = new(Expandable.Projection, "URP"); static readonly AdditionalPropertiesState k_ExpandedAdditionalState = new(0, "URP"); public static readonly CED.IDrawer SectionProjectionSettings = CED.FoldoutGroup( CameraUI.Styles.projectionSettingsHeaderContent, Expandable.Projection, k_ExpandedState, FoldoutOption.Indent, CED.Group( DrawerProjection ), PhysicalCamera.Drawer ); public static readonly CED.IDrawer SectionStackSettings = CED.Conditional( (serialized, editor) => (CameraRenderType)serialized.cameraType.intValue == CameraRenderType.Base, CED.FoldoutGroup(Styles.stackSettingsText, Expandable.Stack, k_ExpandedState, FoldoutOption.Indent, CED.Group(DrawerStackCameras))); public static readonly CED.IDrawer[] Inspector = { CED.Group( DrawerCameraType ), SectionProjectionSettings, Rendering.Drawer, SectionStackSettings, Environment.Drawer, Output.Drawer }; static void DrawerProjection(UniversalRenderPipelineSerializedCamera p, Editor owner) { var camera = p.serializedObject.targetObject as Camera; bool pixelPerfectEnabled = camera.TryGetComponent(out var pixelPerfectCamera) && pixelPerfectCamera.enabled; if (pixelPerfectEnabled) EditorGUILayout.HelpBox(Styles.pixelPerfectInfo, MessageType.Info); using (new EditorGUI.DisabledGroupScope(pixelPerfectEnabled)) CameraUI.Drawer_Projection(p, owner); } static void DrawerCameraType(UniversalRenderPipelineSerializedCamera p, Editor owner) { int selectedRenderer = p.renderer.intValue; ScriptableRenderer scriptableRenderer = UniversalRenderPipeline.asset.GetRenderer(selectedRenderer); bool isDeferred = scriptableRenderer is UniversalRenderer { renderingModeRequested: RenderingMode.Deferred }; EditorGUI.BeginChangeCheck(); CameraRenderType originalCamType = (CameraRenderType)p.cameraType.intValue; CameraRenderType camType = scriptableRenderer.SupportsCameraStackingType(CameraRenderType.Overlay) ? originalCamType : CameraRenderType.Base; EditorGUI.BeginDisabledGroup(scriptableRenderer.SupportedCameraStackingTypes() == 0); camType = (CameraRenderType)EditorGUILayout.EnumPopup( Styles.cameraType, camType, e => scriptableRenderer.SupportsCameraStackingType((CameraRenderType)e), false ); EditorGUI.EndDisabledGroup(); if (EditorGUI.EndChangeCheck() || camType != originalCamType) { p.cameraType.intValue = (int)camType; if (camType == CameraRenderType.Overlay) { p.baseCameraSettings.clearFlags.intValue = (int)CameraClearFlags.Nothing; } } EditorGUILayout.Space(); } static void DrawerStackCameras(UniversalRenderPipelineSerializedCamera p, Editor owner) { if (owner is UniversalRenderPipelineCameraEditor cameraEditor) { cameraEditor.DrawStackSettings(); } } } }