2026-10-21 20:45:23 +01:00
using UnityEngine ;
using UnityEngine.Rendering.Universal ;
namespace UnityEditor.Rendering.Universal
{
using CED = CoreEditorDrawer < UniversalRenderPipelineSerializedCamera >;
static partial class UniversalRenderPipelineCameraUI
{
2026-11-30 19:13:17 +00:00
[URPHelpURL("urp/camera-component-reference")]
2026-10-21 20:45:23 +01:00
public enum Expandable
{
/// <summary> Projection</summary>
Projection = 1 << 0 ,
/// <summary> Physical</summary>
Physical = 1 << 1 ,
/// <summary> Output</summary>
Output = 1 << 2 ,
/// <summary> Orthographic</summary>
Orthographic = 1 << 3 ,
/// <summary> RenderLoop</summary>
RenderLoop = 1 << 4 ,
/// <summary> Rendering</summary>
Rendering = 1 << 5 ,
/// <summary> Environment</summary>
Environment = 1 << 6 ,
/// <summary> Stack</summary>
Stack = 1 << 7 ,
}
public enum ExpandableAdditional
{
/// <summary> Rendering</summary>
Rendering = 1 << 0 ,
}
static readonly ExpandedState < Expandable , Camera > k_ExpandedState = new ( Expandable . Projection , "URP" );
static readonly AdditionalPropertiesState < ExpandableAdditional , Camera > 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 < PixelPerfectCamera >( out var pixelPerfectCamera ) && pixelPerfectCamera . enabled ;
if ( pixelPerfectEnabled )
EditorGUILayout . HelpBox ( Styles . pixelPerfectInfo , MessageType . Info );
2026-11-30 19:13:17 +00:00
#if XR_MANAGEMENT_4_0_1_OR_NEWER && ENABLE_VR && ENABLE_XR_MODULE
if ( p . baseCameraSettings . orthographic . boolValue && p . allowXRRendering . boolValue )
{
var buildTargetGroup = BuildPipeline . GetBuildTargetGroup ( EditorUserBuildSettings . activeBuildTarget );
var buildTargetSettings = XR . Management . XRGeneralSettingsPerBuildTarget . XRGeneralSettingsForBuildTarget ( buildTargetGroup );
if ( buildTargetSettings != null && buildTargetSettings . AssignedSettings != null && buildTargetSettings . AssignedSettings . activeLoaders . Count > 0 )
{
EditorGUILayout . HelpBox ( "Orthographic projection is not supported in XR. Please change the Camera Projection setting to Perspective to avoid rendering issues" , MessageType . Warning );
}
2026-10-21 20:45:23 +01:00
2026-11-30 19:13:17 +00:00
}
#endif
2026-10-21 20:45:23 +01:00
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 );
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 ();
}
}
}
}