initial commit

This commit is contained in:
Jo 2025-01-07 02:06:59 +01:00
parent 6715289efe
commit 788c3389af
37645 changed files with 2526849 additions and 80 deletions

View file

@ -0,0 +1,505 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEditor.SceneManagement;
using UnityEditorInternal;
using UnityEngine;
using UnityEngine.Rendering.Universal;
namespace UnityEditor.Rendering.Universal
{
using Styles = UniversalRenderPipelineCameraUI.Styles;
[CustomEditorForRenderPipeline(typeof(Camera), typeof(UniversalRenderPipelineAsset))]
[CanEditMultipleObjects]
class UniversalRenderPipelineCameraEditor : CameraEditor
{
ReorderableList m_LayerList;
public Camera camera => target as Camera;
List<Camera> validCameras = new List<Camera>();
List<Camera> m_TypeErrorCameras = new List<Camera>();
List<Camera> m_OutputWarningCameras = new List<Camera>();
UniversalRenderPipelineSerializedCamera m_SerializedCamera;
public new void OnEnable()
{
base.OnEnable();
settings.OnEnable();
m_SerializedCamera = new UniversalRenderPipelineSerializedCamera(serializedObject, settings);
validCameras.Clear();
m_TypeErrorCameras.Clear();
m_OutputWarningCameras.Clear();
UpdateCameras();
}
void UpdateCameras()
{
m_SerializedCamera.Refresh();
m_LayerList = new ReorderableList(m_SerializedCamera.serializedObject, m_SerializedCamera.cameras, true, true, true, true)
{
drawHeaderCallback = rect => EditorGUI.LabelField(rect, Styles.cameras),
drawElementCallback = DrawElementCallback,
onSelectCallback = SelectElement,
onRemoveCallback = RemoveCamera,
onCanRemoveCallback = CanRemoveCamera,
onAddDropdownCallback = AddCameraToCameraList
};
}
bool CanRemoveCamera(ReorderableList list) => m_SerializedCamera.numCameras > 0;
void RemoveCamera(ReorderableList list)
{
// As multi selection is disabled, selectedIndices will only return 1 element, remove that element from the list
if (list.selectedIndices.Any())
{
m_SerializedCamera.cameras.DeleteArrayElementAtIndex(list.selectedIndices.First());
}
else
{
// Nothing selected, remove the last item on the list
ReorderableList.defaultBehaviours.DoRemoveButton(list);
}
// Force update the list as removed camera could been there
m_TypeErrorCameras.Clear();
m_OutputWarningCameras.Clear();
}
void SelectElement(ReorderableList list)
{
var element = m_SerializedCamera.cameras.GetArrayElementAtIndex(list.index);
var cam = element.objectReferenceValue as Camera;
if (Event.current.clickCount == 2)
{
Selection.activeObject = cam;
}
EditorGUIUtility.PingObject(cam);
}
void DrawElementCallback(Rect rect, int index, bool isActive, bool isFocused)
{
rect.height = EditorGUIUtility.singleLineHeight;
rect.y += 1;
(Camera camera, UniversalRenderPipelineSerializedCamera serializedCamera) overlayCamera = m_SerializedCamera[index];
Camera cam = overlayCamera.camera;
if (cam != null)
{
bool typeError = false;
var type = cam.gameObject.GetComponent<UniversalAdditionalCameraData>().renderType;
if (type != CameraRenderType.Overlay)
{
typeError = true;
if (!m_TypeErrorCameras.Contains(cam))
{
m_TypeErrorCameras.Add(cam);
}
}
else if (m_TypeErrorCameras.Contains(cam))
{
m_TypeErrorCameras.Remove(cam);
}
bool outputWarning = false;
if (IsStackCameraOutputDirty(cam, overlayCamera.serializedCamera))
{
outputWarning = true;
if (!m_OutputWarningCameras.Contains(cam))
{
m_OutputWarningCameras.Add(cam);
}
}
else if (m_OutputWarningCameras.Contains(cam))
{
m_OutputWarningCameras.Remove(cam);
}
GUIContent nameContent =
outputWarning ?
EditorGUIUtility.TrTextContent(cam.name, "Output properties do not match base camera", CoreEditorStyles.iconWarn) :
EditorGUIUtility.TrTextContent(cam.name);
GUIContent typeContent =
typeError ?
EditorGUIUtility.TrTextContent(type.GetName(), "Not a supported type", CoreEditorStyles.iconFail) :
EditorGUIUtility.TrTextContent(type.GetName());
EditorGUI.BeginProperty(rect, GUIContent.none, m_SerializedCamera.cameras.GetArrayElementAtIndex(index));
var labelWidth = EditorGUIUtility.labelWidth;
EditorGUIUtility.labelWidth -= 20f;
using (var iconSizeScope = new EditorGUIUtility.IconSizeScope(new Vector2(rect.height, rect.height)))
{
EditorGUI.LabelField(rect, nameContent, typeContent);
}
// Printing if Post Processing is on or not.
var isPostActive = cam.gameObject.GetComponent<UniversalAdditionalCameraData>().renderPostProcessing;
if (isPostActive)
{
Rect selectRect = new Rect(rect.width - 20, rect.y, 50, EditorGUIUtility.singleLineHeight);
EditorGUI.LabelField(selectRect, "PP");
}
EditorGUI.EndProperty();
EditorGUIUtility.labelWidth = labelWidth;
}
else
{
camera.GetComponent<UniversalAdditionalCameraData>().UpdateCameraStack();
// Need to clean out the errorCamera list here.
m_TypeErrorCameras.Clear();
m_OutputWarningCameras.Clear();
}
}
// Modified version of StageHandle.FindComponentsOfType<T>()
// This version more closely represents unity object referencing restrictions.
// I added these restrictions:
// - Can not reference scene object outside scene
// - Can not reference cross scenes
// - Can reference child objects if it is prefab
Camera[] FindCamerasToReference(GameObject gameObject)
{
var scene = gameObject.scene;
var inScene = !EditorUtility.IsPersistent(camera) || scene.IsValid();
var inPreviewScene = EditorSceneManager.IsPreviewScene(scene) && scene.IsValid();
var inCurrentScene = !EditorUtility.IsPersistent(camera) && scene.IsValid();
Camera[] cameras = Resources.FindObjectsOfTypeAll<Camera>();
List<Camera> result = new List<Camera>();
if (!inScene)
{
foreach (var camera in cameras)
{
if (camera.transform.IsChildOf(gameObject.transform))
result.Add(camera);
}
}
else if (inPreviewScene)
{
foreach (var camera in cameras)
{
if (camera.gameObject.scene == scene)
result.Add(camera);
}
}
else if (inCurrentScene)
{
foreach (var camera in cameras)
{
if (!EditorUtility.IsPersistent(camera) && !EditorSceneManager.IsPreviewScene(camera.gameObject.scene) && camera.gameObject.scene == scene)
result.Add(camera);
}
}
return result.ToArray();
}
void AddCameraToCameraList(Rect rect, ReorderableList list)
{
// Need to do clear the list here otherwise the meu just fills up with more and more entries
validCameras.Clear();
var allCameras = FindCamerasToReference(camera.gameObject);
foreach (var camera in allCameras)
{
var component = camera.gameObject.GetComponent<UniversalAdditionalCameraData>();
if (component != null)
{
if (component.renderType == CameraRenderType.Overlay)
{
validCameras.Add(camera);
}
}
}
var names = new GUIContent[validCameras.Count];
for (int i = 0; i < validCameras.Count; ++i)
{
names[i] = new GUIContent((i + 1) + " " + validCameras[i].name);
}
if (!validCameras.Any())
{
names = new GUIContent[1];
names[0] = new GUIContent("No Overlay Cameras exist.");
}
EditorUtility.DisplayCustomMenu(rect, names, -1, AddCameraToCameraListMenuSelected, null);
}
void AddCameraToCameraListMenuSelected(object userData, string[] options, int selected)
{
if (!validCameras.Any())
return;
m_SerializedCamera.cameras.InsertArrayElementAtIndex(m_SerializedCamera.numCameras);
m_SerializedCamera.cameras.GetArrayElementAtIndex(m_SerializedCamera.numCameras - 1).objectReferenceValue = validCameras[selected];
m_SerializedCamera.serializedAdditionalDataObject.ApplyModifiedProperties();
m_SerializedCamera.Refresh();
(Camera camera, UniversalRenderPipelineSerializedCamera serializedCamera) overlayCamera = m_SerializedCamera[m_SerializedCamera.numCameras - 1];
UpdateStackCameraOutput(overlayCamera.camera, overlayCamera.serializedCamera);
}
public new void OnDisable()
{
base.OnDisable();
}
// IsPreset is an internal API - lets reuse the usable part of this function
// 93 is a "magic number" and does not represent a combination of other flags here
internal static bool IsPresetEditor(UnityEditor.Editor editor)
{
return (int)((editor.target as Component).gameObject.hideFlags) == 93;
}
public override void OnInspectorGUI()
{
var rpAsset = UniversalRenderPipeline.asset;
if (rpAsset == null)
{
base.OnInspectorGUI();
return;
}
m_SerializedCamera.Update();
if (IsPresetEditor(this))
{
UniversalRenderPipelineCameraUI.PresetInspector.Draw(m_SerializedCamera, this);
}
else
{
UniversalRenderPipelineCameraUI.Inspector.Draw(m_SerializedCamera, this);
}
m_SerializedCamera.Apply();
}
private void UpdateStackCamerasToOverlay()
{
int cameraCount = m_SerializedCamera.cameras.arraySize;
for (int i = 0; i < cameraCount; ++i)
{
SerializedProperty cameraProperty = m_SerializedCamera.cameras.GetArrayElementAtIndex(i);
var camera = cameraProperty.objectReferenceValue as Camera;
if (camera == null)
continue;
var additionalCameraData = camera.GetComponent<UniversalAdditionalCameraData>();
if (additionalCameraData == null)
continue;
Undo.RecordObject(camera, Styles.inspectorOverlayCameraText);
if (additionalCameraData.renderType == CameraRenderType.Base)
{
additionalCameraData.renderType = CameraRenderType.Overlay;
EditorUtility.SetDirty(camera);
}
}
}
private void UpdateStackCamerasOutput()
{
int cameraCount = m_SerializedCamera.cameras.arraySize;
for (int i = 0; i < cameraCount; ++i)
{
(Camera camera, UniversalRenderPipelineSerializedCamera serializedCamera) overlayCamera = m_SerializedCamera[i];
if (overlayCamera.camera != null)
UpdateStackCameraOutput(overlayCamera.camera, overlayCamera.serializedCamera);
}
}
private void UpdateStackCameraOutput(Camera cam, UniversalRenderPipelineSerializedCamera serializedCamera)
{
if ((CameraRenderType)serializedCamera.cameraType.intValue == CameraRenderType.Base)
return;
serializedCamera.Update();
Undo.RecordObject(camera, Styles.inspectorOverlayCameraText);
var serializedCameraSettings = serializedCamera.baseCameraSettings;
bool isChanged = false;
// Force same render texture
RenderTexture targetTexture = settings.targetTexture.objectReferenceValue as RenderTexture;
if (cam.targetTexture != targetTexture)
{
cam.targetTexture = targetTexture;
isChanged = true;
}
// Force same hdr
bool allowHDR = settings.HDR.boolValue;
if (cam.allowHDR != allowHDR)
{
cam.allowHDR = allowHDR;
isChanged = true;
}
// Force same mssa
bool allowMSSA = settings.allowMSAA.boolValue;
if (cam.allowMSAA != allowMSSA)
{
cam.allowMSAA = allowMSSA;
isChanged = true;
}
// Force same viewport rect
Rect rect = settings.normalizedViewPortRect.rectValue;
if (cam.rect != rect)
{
cam.rect = settings.normalizedViewPortRect.rectValue;
isChanged = true;
}
// Force same dynamic resolution
bool allowDynamicResolution = settings.allowDynamicResolution.boolValue;
if (serializedCamera.allowDynamicResolution.boolValue != allowDynamicResolution)
{
cam.allowDynamicResolution = allowDynamicResolution;
isChanged = true;
}
// Force same target display
int targetDisplay = settings.targetDisplay.intValue;
if (cam.targetDisplay != targetDisplay)
{
cam.targetDisplay = targetDisplay;
isChanged = true;
}
#if ENABLE_VR && ENABLE_XR_MODULE
// Force same target display
int selectedValue = !m_SerializedCamera.allowXRRendering.boolValue ? 0 : 1;
int overlayCameraSelectedValue = !serializedCamera.allowXRRendering.boolValue ? 0 : 1;
if (overlayCameraSelectedValue != selectedValue)
{
serializedCamera.allowXRRendering.boolValue = selectedValue == 1;
isChanged = true;
}
#endif
if (isChanged)
{
EditorUtility.SetDirty(cam);
serializedCamera.Apply();
}
}
private bool IsStackCameraOutputDirty(Camera cam, UniversalRenderPipelineSerializedCamera serializedCamera)
{
serializedCamera.Update();
// Force same render texture
RenderTexture targetTexture = settings.targetTexture.objectReferenceValue as RenderTexture;
if (cam.targetTexture != targetTexture)
return true;
// Force same hdr
bool allowHDR = settings.HDR.boolValue;
if (cam.allowHDR != allowHDR)
return true;
// Force same mssa
bool allowMSSA = settings.allowMSAA.boolValue;
if (cam.allowMSAA != allowMSSA)
return true;
// Force same viewport rect
Rect rect = settings.normalizedViewPortRect.rectValue;
if (cam.rect != rect)
return true;
// Force same dynamic resolution
bool allowDynamicResolution = settings.allowDynamicResolution.boolValue;
if (serializedCamera.allowDynamicResolution.boolValue != allowDynamicResolution)
return true;
// Force same target display
int targetDisplay = settings.targetDisplay.intValue;
if (cam.targetDisplay != targetDisplay)
return true;
#if ENABLE_VR && ENABLE_XR_MODULE
// Force same target display
int selectedValue = !m_SerializedCamera.allowXRRendering.boolValue ? 0 : 1;
int overlayCameraSelectedValue = !serializedCamera.allowXRRendering.boolValue ? 0 : 1;
if (overlayCameraSelectedValue != selectedValue)
return true;
#endif
return false;
}
internal void DrawStackSettings()
{
if (m_SerializedCamera.cameras.hasMultipleDifferentValues)
{
EditorGUILayout.HelpBox("Cannot multi edit stack of multiple cameras.", MessageType.Info);
EditorGUILayout.EndFoldoutHeaderGroup();
return;
}
bool cameraStackingAvailable = m_SerializedCamera
.camerasAdditionalData
.All(c => c.scriptableRenderer?.supportedRenderingFeatures?.cameraStacking ?? false);
if (!cameraStackingAvailable)
{
EditorGUILayout.HelpBox("The renderer used by this camera doesn't support camera stacking. Only Base camera will render.", MessageType.Warning);
return;
}
EditorGUILayout.Space();
m_LayerList.DoLayoutList();
m_SerializedCamera.Apply();
EditorGUI.indentLevel--;
if (m_TypeErrorCameras.Any())
{
var message = new StringBuilder();
message.Append("The type of the following Cameras must be Overlay render type: ");
foreach (var cam in m_TypeErrorCameras)
{
message.Append(cam.name);
message.Append(cam != m_TypeErrorCameras.Last() ? ", " : ".");
}
CoreEditorUtils.DrawFixMeBox(message.ToString(), MessageType.Error, UpdateStackCamerasToOverlay);
}
if (m_OutputWarningCameras.Any())
{
var message = new StringBuilder();
message.Append("The output properties of this Camera do not match the output properties of the following Cameras: ");
foreach (var cam in m_OutputWarningCameras)
{
message.Append(cam.name);
message.Append(cam != m_OutputWarningCameras.Last() ? ", " : ".");
}
CoreEditorUtils.DrawFixMeBox(message.ToString(), MessageType.Warning, () => UpdateStackCamerasOutput());
}
EditorGUI.indentLevel++;
EditorGUILayout.Space();
}
}
}

View file

@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: d569aa2a3d2a1a74aaf68c388f2e0798
timeCreated: 1509983694
licenseType: Pro
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,106 @@
using UnityEngine;
using UnityEngine.Rendering.Universal;
namespace UnityEditor.Rendering.Universal
{
using CED = CoreEditorDrawer<UniversalRenderPipelineSerializedCamera>;
static partial class UniversalRenderPipelineCameraUI
{
[URPHelpURL("camera-component-reference")]
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,
}
static readonly ExpandedState<Expandable, Camera> k_ExpandedState = new(Expandable.Projection, "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<UnityEngine.Experimental.Rendering.Universal.PixelPerfectCamera>(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 { renderingMode: RenderingMode.Deferred };
EditorGUI.BeginChangeCheck();
CameraRenderType originalCamType = (CameraRenderType)p.cameraType.intValue;
CameraRenderType camType = (originalCamType != CameraRenderType.Base && isDeferred) ? CameraRenderType.Base : originalCamType;
camType = (CameraRenderType)EditorGUILayout.EnumPopup(
Styles.cameraType,
camType,
e => !isDeferred || (CameraRenderType)e != CameraRenderType.Overlay,
false
);
if (EditorGUI.EndChangeCheck() || camType != originalCamType)
{
p.cameraType.intValue = (int)camType;
}
EditorGUILayout.Space();
}
static void DrawerStackCameras(UniversalRenderPipelineSerializedCamera p, Editor owner)
{
if (owner is UniversalRenderPipelineCameraEditor cameraEditor)
{
cameraEditor.DrawStackSettings();
}
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 351a090b57ba63848bc96f8dcde61a72
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,131 @@
namespace UnityEditor.Rendering.Universal
{
using UnityEngine;
using UnityEngine.Rendering.Universal;
using CED = CoreEditorDrawer<UniversalRenderPipelineSerializedCamera>;
static partial class UniversalRenderPipelineCameraUI
{
public partial class Environment
{
internal enum BackgroundType
{
Skybox = 0,
SolidColor,
[InspectorName("Uninitialized")]
DontCare,
}
public static readonly CED.IDrawer Drawer = CED.FoldoutGroup(
CameraUI.Environment.Styles.header,
Expandable.Environment,
k_ExpandedState,
FoldoutOption.Indent,
CED.Conditional(
(serialized, owner) => (CameraRenderType)serialized.cameraType.intValue == CameraRenderType.Base,
CED.Group(
Drawer_Environment_ClearFlags
)
),
CED.Group(
Styles.volumesSettingsText,
CED.Group(
GroupOption.Indent,
Drawer_Environment_VolumeUpdate,
CameraUI.Environment.Drawer_Environment_VolumeLayerMask,
Drawer_Environment_VolumeTrigger
)
)
);
static BackgroundType GetBackgroundType(CameraClearFlags clearFlags)
{
switch (clearFlags)
{
case CameraClearFlags.Skybox:
return BackgroundType.Skybox;
case CameraClearFlags.Nothing:
return BackgroundType.DontCare;
// DepthOnly is not supported by design in UniversalRP. We upgrade it to SolidColor
default:
return BackgroundType.SolidColor;
}
}
static void Drawer_Environment_ClearFlags(UniversalRenderPipelineSerializedCamera p, Editor owner)
{
EditorGUI.showMixedValue = p.baseCameraSettings.clearFlags.hasMultipleDifferentValues;
Rect clearFlagsRect = EditorGUILayout.GetControlRect();
EditorGUI.BeginProperty(clearFlagsRect, Styles.backgroundType, p.baseCameraSettings.clearFlags);
{
EditorGUI.BeginChangeCheck();
BackgroundType backgroundType = GetBackgroundType((CameraClearFlags)p.baseCameraSettings.clearFlags.intValue);
var selectedValue = (BackgroundType)EditorGUI.EnumPopup(clearFlagsRect, Styles.backgroundType, backgroundType);
if (EditorGUI.EndChangeCheck())
{
CameraClearFlags selectedClearFlags;
switch (selectedValue)
{
case BackgroundType.Skybox:
selectedClearFlags = CameraClearFlags.Skybox;
break;
case BackgroundType.DontCare:
selectedClearFlags = CameraClearFlags.Nothing;
break;
default:
selectedClearFlags = CameraClearFlags.SolidColor;
break;
}
p.baseCameraSettings.clearFlags.intValue = (int)selectedClearFlags;
}
if (!p.baseCameraSettings.clearFlags.hasMultipleDifferentValues)
{
if (GetBackgroundType((CameraClearFlags)p.baseCameraSettings.clearFlags.intValue) == BackgroundType.SolidColor)
{
using (var group = new EditorGUI.IndentLevelScope())
{
p.baseCameraSettings.DrawBackgroundColor();
}
}
}
}
EditorGUI.EndProperty();
EditorGUI.showMixedValue = false;
}
static void Drawer_Environment_VolumeUpdate(UniversalRenderPipelineSerializedCamera p, Editor owner)
{
EditorGUI.BeginChangeCheck();
VolumeFrameworkUpdateMode prevVolumeUpdateMode = (VolumeFrameworkUpdateMode)p.volumeFrameworkUpdateMode.intValue;
EditorGUILayout.PropertyField(p.volumeFrameworkUpdateMode, Styles.volumeUpdates);
if (EditorGUI.EndChangeCheck())
{
if (p.serializedObject.targetObject is not Camera cam)
return;
VolumeFrameworkUpdateMode curVolumeUpdateMode = (VolumeFrameworkUpdateMode)p.volumeFrameworkUpdateMode.intValue;
cam.SetVolumeFrameworkUpdateMode(curVolumeUpdateMode);
}
}
static void Drawer_Environment_VolumeTrigger(UniversalRenderPipelineSerializedCamera p, Editor owner)
{
var controlRect = EditorGUILayout.GetControlRect(true);
EditorGUI.BeginProperty(controlRect, Styles.volumeTrigger, p.volumeTrigger);
{
EditorGUI.BeginChangeCheck();
var newValue = EditorGUI.ObjectField(controlRect, Styles.volumeTrigger, (Transform)p.volumeTrigger.objectReferenceValue, typeof(Transform), true);
if (EditorGUI.EndChangeCheck() && !Equals(p.volumeTrigger.objectReferenceValue, newValue))
p.volumeTrigger.objectReferenceValue = newValue;
}
EditorGUI.EndProperty();
}
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b68aaae4e9af09d4d965e4cc2f6c8fcd
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,18 @@
using UnityEngine;
namespace UnityEditor.Rendering.Universal
{
static partial class UniversalRenderPipelineCameraUI
{
public partial class Environment
{
public class Styles
{
public static GUIContent backgroundType = EditorGUIUtility.TrTextContent("Background Type", "Controls how to initialize the Camera's background.\n\nSkybox initializes camera with Skybox, defaulting to a background color if no skybox is found.\n\nSolid Color initializes background with the background color.\n\nUninitialized has undefined values for the camera background. Use this only if you are rendering all pixels in the Camera's view.");
public static GUIContent volumesSettingsText = EditorGUIUtility.TrTextContent("Volumes", "These settings define how Volumes affect this Camera.");
public static GUIContent volumeTrigger = EditorGUIUtility.TrTextContent("Volume Trigger", "A transform that will act as a trigger for volume blending. If none is set, the camera itself will act as a trigger.");
public static GUIContent volumeUpdates = EditorGUIUtility.TrTextContent("Update Mode", "Select how Unity updates Volumes: every frame or when triggered via scripting. In the Editor, Unity updates Volumes every frame when not in the Play mode.");
}
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2a4aae3b1d854784897c1039b8168a08
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,245 @@
using System;
using UnityEngine;
using UnityEngine.Rendering.Universal;
namespace UnityEditor.Rendering.Universal
{
using CED = CoreEditorDrawer<UniversalRenderPipelineSerializedCamera>;
static partial class UniversalRenderPipelineCameraUI
{
public partial class Output
{
public static readonly CED.IDrawer Drawer = CED.Conditional(
(serialized, owner) => (CameraRenderType)serialized.cameraType.intValue == CameraRenderType.Base,
CED.FoldoutGroup(
CameraUI.Output.Styles.header,
Expandable.Output,
k_ExpandedState,
FoldoutOption.Indent,
CED.Group(
DrawerOutputTargetTexture
),
CED.Conditional(
(serialized, owner) => serialized.serializedObject.targetObject is Camera camera && camera.targetTexture == null,
CED.Group(
DrawerOutputMultiDisplay
)
),
#if ENABLE_VR && ENABLE_XR_MODULE
CED.Group(DrawerOutputXRRendering),
#endif
CED.Group(
DrawerOutputNormalizedViewPort
),
CED.Conditional(
(serialized, owner) => serialized.serializedObject.targetObject is Camera camera && camera.targetTexture == null,
CED.Group(
DrawerOutputHDR,
DrawerOutputMSAA,
DrawerOutputAllowDynamicResolution
)
)
)
);
static void DrawerOutputMultiDisplay(UniversalRenderPipelineSerializedCamera p, Editor owner)
{
using (var checkScope = new EditorGUI.ChangeCheckScope())
{
p.baseCameraSettings.DrawMultiDisplay();
if (checkScope.changed)
{
UpdateStackCamerasOutput(p, camera =>
{
bool isChanged = false;
// Force same target display
int targetDisplay = p.baseCameraSettings.targetDisplay.intValue;
if (camera.targetDisplay != targetDisplay)
{
camera.targetDisplay = targetDisplay;
isChanged = true;
}
// Force same target display
StereoTargetEyeMask stereoTargetEye = (StereoTargetEyeMask)p.baseCameraSettings.targetEye.intValue;
if (camera.stereoTargetEye != stereoTargetEye)
{
camera.stereoTargetEye = stereoTargetEye;
isChanged = true;
}
return isChanged;
});
}
}
}
static void DrawerOutputAllowDynamicResolution(UniversalRenderPipelineSerializedCamera p, Editor owner)
{
using (var checkScope = new EditorGUI.ChangeCheckScope())
{
CameraUI.Output.Drawer_Output_AllowDynamicResolution(p, owner);
if (checkScope.changed)
{
UpdateStackCamerasOutput(p, camera =>
{
bool allowDynamicResolution = p.allowDynamicResolution.boolValue;
if (camera.allowDynamicResolution == p.allowDynamicResolution.boolValue)
return false;
EditorUtility.SetDirty(camera);
camera.allowDynamicResolution = allowDynamicResolution;
return true;
});
}
}
}
static void DrawerOutputNormalizedViewPort(UniversalRenderPipelineSerializedCamera p, Editor owner)
{
using (var checkScope = new EditorGUI.ChangeCheckScope())
{
CameraUI.Output.Drawer_Output_NormalizedViewPort(p, owner);
if (checkScope.changed)
{
UpdateStackCamerasOutput(p, camera =>
{
Rect rect = p.baseCameraSettings.normalizedViewPortRect.rectValue;
if (camera.rect != rect)
{
camera.rect = p.baseCameraSettings.normalizedViewPortRect.rectValue;
return true;
}
return false;
});
}
}
}
static void UpdateStackCamerasOutput(UniversalRenderPipelineSerializedCamera p, Func<Camera, bool> updateOutputProperty)
{
int cameraCount = p.cameras.arraySize;
for (int i = 0; i < cameraCount; ++i)
{
SerializedProperty cameraProperty = p.cameras.GetArrayElementAtIndex(i);
Camera overlayCamera = cameraProperty.objectReferenceValue as Camera;
if (overlayCamera != null)
{
Undo.RecordObject(overlayCamera, Styles.inspectorOverlayCameraText);
if (updateOutputProperty(overlayCamera))
EditorUtility.SetDirty(overlayCamera);
}
}
}
static void DrawerOutputTargetTexture(UniversalRenderPipelineSerializedCamera p, Editor owner)
{
var rpAsset = UniversalRenderPipeline.asset;
using (var checkScope = new EditorGUI.ChangeCheckScope())
{
EditorGUILayout.PropertyField(p.baseCameraSettings.targetTexture, Styles.targetTextureLabel);
var texture = p.baseCameraSettings.targetTexture.objectReferenceValue as RenderTexture;
if (!p.baseCameraSettings.targetTexture.hasMultipleDifferentValues && rpAsset != null)
{
int pipelineSamplesCount = rpAsset.msaaSampleCount;
if (texture && texture.antiAliasing > pipelineSamplesCount)
{
string pipelineMSAACaps = (pipelineSamplesCount > 1) ? string.Format(Styles.pipelineMSAACapsSupportSamples, pipelineSamplesCount) : Styles.pipelineMSAACapsDisabled;
EditorGUILayout.HelpBox(string.Format(Styles.cameraTargetTextureMSAA, texture.antiAliasing, pipelineMSAACaps), MessageType.Warning, true);
}
}
if (checkScope.changed)
{
UpdateStackCamerasOutput(p, camera =>
{
if (camera.targetTexture == texture)
return false;
camera.targetTexture = texture;
return true;
});
}
}
}
#if ENABLE_VR && ENABLE_XR_MODULE
static void DrawerOutputXRRendering(UniversalRenderPipelineSerializedCamera p, Editor owner)
{
Rect controlRect = EditorGUILayout.GetControlRect(true);
EditorGUI.BeginProperty(controlRect, Styles.xrTargetEye, p.allowXRRendering);
{
using (var checkScope = new EditorGUI.ChangeCheckScope())
{
int selectedValue = !p.allowXRRendering.boolValue ? 0 : 1;
bool allowXRRendering = EditorGUI.IntPopup(controlRect, Styles.xrTargetEye, selectedValue, Styles.xrTargetEyeOptions, Styles.xrTargetEyeValues) == 1;
if (checkScope.changed)
p.allowXRRendering.boolValue = allowXRRendering;
}
}
EditorGUI.EndProperty();
}
#endif
static void DrawerOutputHDR(UniversalRenderPipelineSerializedCamera p, Editor owner)
{
Rect controlRect = EditorGUILayout.GetControlRect(true);
EditorGUI.BeginProperty(controlRect, Styles.allowHDR, p.baseCameraSettings.HDR);
{
using (var checkScope = new EditorGUI.ChangeCheckScope())
{
int selectedValue = !p.baseCameraSettings.HDR.boolValue ? 0 : 1;
var allowHDR = EditorGUI.IntPopup(controlRect, Styles.allowHDR, selectedValue, Styles.displayedCameraOptions, Styles.cameraOptions) == 1;
if (checkScope.changed)
{
p.baseCameraSettings.HDR.boolValue = allowHDR;
UpdateStackCamerasOutput(p, camera =>
{
if (camera.allowHDR == allowHDR)
return false;
camera.allowHDR = allowHDR;
return true;
});
}
}
}
EditorGUI.EndProperty();
}
static void DrawerOutputMSAA(UniversalRenderPipelineSerializedCamera p, Editor owner)
{
Rect controlRect = EditorGUILayout.GetControlRect(true);
EditorGUI.BeginProperty(controlRect, Styles.allowMSAA, p.baseCameraSettings.allowMSAA);
{
using (var checkScope = new EditorGUI.ChangeCheckScope())
{
int selectedValue = !p.baseCameraSettings.allowMSAA.boolValue ? 0 : 1;
var allowMSAA = EditorGUI.IntPopup(controlRect, Styles.allowMSAA,
selectedValue, Styles.displayedCameraOptions, Styles.cameraOptions) == 1;
if (checkScope.changed)
{
p.baseCameraSettings.allowMSAA.boolValue = allowMSAA;
UpdateStackCamerasOutput(p, camera =>
{
if (camera.allowMSAA == allowMSAA)
return false;
camera.allowMSAA = allowMSAA;
return true;
});
}
}
}
EditorGUI.EndProperty();
}
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5a6bc694ac42d3343b113dd49606145c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,43 @@
using UnityEngine;
namespace UnityEditor.Rendering.Universal
{
static partial class UniversalRenderPipelineCameraUI
{
public partial class Output
{
public class Styles
{
#if ENABLE_VR && ENABLE_XR_MODULE
public static GUIContent[] xrTargetEyeOptions =
{
EditorGUIUtility.TrTextContent("None"),
EditorGUIUtility.TrTextContent("Both"),
};
public static int[] xrTargetEyeValues = { 0, 1 };
public static readonly GUIContent xrTargetEye = EditorGUIUtility.TrTextContent("Target Eye",
"Allows XR rendering if target eye sets to both eye. Disable XR for this camera otherwise.");
#endif
// Using the pipeline Settings
public static GUIContent[] displayedCameraOptions =
{
EditorGUIUtility.TrTextContent("Off"),
EditorGUIUtility.TrTextContent("Use settings from Render Pipeline Asset"),
};
public static int[] cameraOptions = { 0, 1 };
public static readonly GUIContent targetTextureLabel = EditorGUIUtility.TrTextContent("Output Texture", "The texture to render this camera into, if none then this camera renders to screen.");
public static string inspectorOverlayCameraText = L10n.Tr("Inspector Overlay Camera");
public static GUIContent allowMSAA = EditorGUIUtility.TrTextContent("MSAA", "Enables Multi-Sample Anti-Aliasing, a technique that smooths jagged edges.");
public static GUIContent allowHDR = EditorGUIUtility.TrTextContent("HDR", "High Dynamic Range gives you a wider range of light intensities, so your lighting looks more realistic. With it, you can still see details and experience less saturation even with bright light.", (Texture)null);
public static string cameraTargetTextureMSAA = L10n.Tr("Camera target texture requires {0}x MSAA. Universal pipeline {1}.");
public static string pipelineMSAACapsSupportSamples = L10n.Tr("is set to support {0}x");
public static string pipelineMSAACapsDisabled = L10n.Tr("has MSAA disabled");
}
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: dcc213569e3849641896accd4ad61e24
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,32 @@
namespace UnityEditor.Rendering.Universal
{
using CED = CoreEditorDrawer<UniversalRenderPipelineSerializedCamera>;
static partial class UniversalRenderPipelineCameraUI
{
public partial class PhysicalCamera
{
public static readonly CED.IDrawer Drawer = CED.Conditional(
(serialized, owner) => serialized.projectionMatrixMode.intValue == (int)CameraUI.ProjectionMatrixMode.PhysicalPropertiesBased,
CED.Group(
CameraUI.PhysicalCamera.Styles.cameraBody,
GroupOption.Indent,
CED.Group(
GroupOption.Indent,
CameraUI.PhysicalCamera.Drawer_PhysicalCamera_CameraBody_Sensor,
CameraUI.PhysicalCamera.Drawer_PhysicalCamera_CameraBody_GateFit
)
),
CED.Group(
CameraUI.PhysicalCamera.Styles.lens,
GroupOption.Indent,
CED.Group(
GroupOption.Indent,
CameraUI.PhysicalCamera.Drawer_PhysicalCamera_Lens_FocalLength,
CameraUI.PhysicalCamera.Drawer_PhysicalCamera_Lens_Shift
)
)
);
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 14ecd35dd3ee4504c84e850f72cac9b4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,28 @@
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;
namespace UnityEditor.Rendering.Universal
{
using CED = CoreEditorDrawer<UniversalRenderPipelineSerializedCamera>;
static partial class UniversalRenderPipelineCameraUI
{
static readonly ExpandedState<Expandable, Camera> k_ExpandedStatePreset = new(0, "URP-preset");
public static readonly CED.IDrawer PresetInspector = CED.Group(
CED.Group((serialized, owner) =>
EditorGUILayout.HelpBox(CameraUI.Styles.unsupportedPresetPropertiesMessage, MessageType.Info)),
CED.Group((serialized, owner) => EditorGUILayout.Space()),
CED.FoldoutGroup(
CameraUI.Styles.projectionSettingsHeaderContent,
Expandable.Projection,
k_ExpandedStatePreset,
FoldoutOption.Indent,
CED.Group(
CameraUI.Drawer_Projection),
PhysicalCamera.Drawer),
Rendering.DrawerPreset
);
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 00fb6a10a5e37ea478b701ae3a51736e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,236 @@
using System.Linq;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;
namespace UnityEditor.Rendering.Universal
{
using CED = CoreEditorDrawer<UniversalRenderPipelineSerializedCamera>;
static partial class UniversalRenderPipelineCameraUI
{
public partial class Rendering
{
static bool s_PostProcessingWarningShown = false;
static readonly CED.IDrawer PostProcessingWarningInit = CED.Group(
(serialized, owner) => s_PostProcessingWarningShown = false
);
private static readonly CED.IDrawer PostProcessingWarningDrawer = CED.Conditional(
(serialized, owner) => IsAnyRendererHasPostProcessingEnabled(serialized, UniversalRenderPipeline.asset) && serialized.renderPostProcessing.boolValue,
(serialized, owner) =>
{
EditorGUILayout.HelpBox(Styles.disabledPostprocessing, MessageType.Warning);
s_PostProcessingWarningShown = true;
});
private static readonly CED.IDrawer PostProcessingAAWarningDrawer = CED.Conditional(
(serialized, owner) => !s_PostProcessingWarningShown && IsAnyRendererHasPostProcessingEnabled(serialized, UniversalRenderPipeline.asset) && (AntialiasingMode)serialized.antialiasing.intValue != AntialiasingMode.None,
(serialized, owner) =>
{
EditorGUILayout.HelpBox(Styles.disabledPostprocessing, MessageType.Warning);
s_PostProcessingWarningShown = true;
});
private static readonly CED.IDrawer PostProcessingStopNaNsWarningDrawer = CED.Conditional(
(serialized, owner) => !s_PostProcessingWarningShown && IsAnyRendererHasPostProcessingEnabled(serialized, UniversalRenderPipeline.asset) && serialized.stopNaNs.boolValue,
(serialized, owner) =>
{
EditorGUILayout.HelpBox(Styles.disabledPostprocessing, MessageType.Warning);
s_PostProcessingWarningShown = true;
});
private static readonly CED.IDrawer PostProcessingDitheringWarningDrawer = CED.Conditional(
(serialized, owner) => !s_PostProcessingWarningShown && IsAnyRendererHasPostProcessingEnabled(serialized, UniversalRenderPipeline.asset) && serialized.dithering.boolValue,
(serialized, owner) =>
{
EditorGUILayout.HelpBox(Styles.disabledPostprocessing, MessageType.Warning);
s_PostProcessingWarningShown = true;
});
static readonly CED.IDrawer BaseCameraRenderTypeDrawer = CED.Conditional(
(serialized, owner) => (CameraRenderType)serialized.cameraType.intValue == CameraRenderType.Base,
CED.Group(
DrawerRenderingRenderPostProcessing
),
PostProcessingWarningDrawer,
CED.Group(
DrawerRenderingAntialiasing
),
PostProcessingAAWarningDrawer,
CED.Conditional(
(serialized, owner) => !serialized.antialiasing.hasMultipleDifferentValues,
CED.Group(
GroupOption.Indent,
CED.Conditional(
(serialized, owner) => (AntialiasingMode)serialized.antialiasing.intValue ==
AntialiasingMode.SubpixelMorphologicalAntiAliasing,
CED.Group(
DrawerRenderingSMAAQuality
)
)
)
),
CED.Group(
CameraUI.Rendering.Drawer_Rendering_StopNaNs
),
PostProcessingStopNaNsWarningDrawer,
CED.Conditional(
(serialized, owner) => serialized.stopNaNs.boolValue && CoreEditorUtils.buildTargets.Contains(GraphicsDeviceType.OpenGLES2),
(serialized, owner) => EditorGUILayout.HelpBox(Styles.stopNaNsMessage, MessageType.Warning)
),
CED.Group(
CameraUI.Rendering.Drawer_Rendering_Dithering
),
PostProcessingDitheringWarningDrawer,
CED.Group(
DrawerRenderingRenderShadows,
DrawerRenderingPriority,
DrawerRenderingOpaqueTexture,
DrawerRenderingDepthTexture
)
);
static readonly CED.IDrawer OverlayCameraRenderTypeDrawer = CED.Conditional(
(serialized, owner) => (CameraRenderType)serialized.cameraType.intValue == CameraRenderType.Overlay,
CED.Group(
DrawerRenderingRenderPostProcessing
),
PostProcessingWarningDrawer,
CED.Group(
DrawerRenderingClearDepth,
DrawerRenderingRenderShadows
)
);
public static readonly CED.IDrawer Drawer = CED.FoldoutGroup(
CameraUI.Rendering.Styles.header,
Expandable.Rendering,
k_ExpandedState,
FoldoutOption.Indent,
PostProcessingWarningInit,
CED.Group(
DrawerRenderingRenderer
),
BaseCameraRenderTypeDrawer,
OverlayCameraRenderTypeDrawer,
CED.Group(
CameraUI.Rendering.Drawer_Rendering_CullingMask,
CameraUI.Rendering.Drawer_Rendering_OcclusionCulling
)
);
public static readonly CED.IDrawer DrawerPreset = CED.FoldoutGroup(
CameraUI.Rendering.Styles.header,
Expandable.Rendering,
k_ExpandedState,
FoldoutOption.Indent,
CED.Group(
CameraUI.Rendering.Drawer_Rendering_CullingMask,
CameraUI.Rendering.Drawer_Rendering_OcclusionCulling
)
);
static void DrawerRenderingRenderer(UniversalRenderPipelineSerializedCamera p, Editor owner)
{
var rpAsset = UniversalRenderPipeline.asset;
int selectedRendererOption = p.renderer.intValue;
EditorGUI.BeginChangeCheck();
Rect controlRect = EditorGUILayout.GetControlRect(true);
EditorGUI.BeginProperty(controlRect, Styles.rendererType, p.renderer);
EditorGUI.showMixedValue = p.renderer.hasMultipleDifferentValues;
int selectedRenderer = EditorGUI.IntPopup(controlRect, Styles.rendererType, selectedRendererOption, rpAsset.rendererDisplayList, rpAsset.rendererIndexList);
EditorGUI.EndProperty();
if (!rpAsset.ValidateRendererDataList())
{
EditorGUILayout.HelpBox(Styles.noRendererError, MessageType.Error);
}
else if (!rpAsset.ValidateRendererData(selectedRendererOption))
{
EditorGUILayout.HelpBox(Styles.missingRendererWarning, MessageType.Warning);
var rect = EditorGUI.IndentedRect(EditorGUILayout.GetControlRect());
if (GUI.Button(rect, Styles.selectRenderPipelineAsset))
{
Selection.activeObject = AssetDatabase.LoadAssetAtPath<UniversalRenderPipelineAsset>(AssetDatabase.GetAssetPath(UniversalRenderPipeline.asset));
}
GUILayout.Space(5);
}
if (EditorGUI.EndChangeCheck())
p.renderer.intValue = selectedRenderer;
}
static bool IsAnyRendererHasPostProcessingEnabled(UniversalRenderPipelineSerializedCamera p, UniversalRenderPipelineAsset rpAsset)
{
int selectedRendererOption = p.renderer.intValue;
if (selectedRendererOption < -1 || selectedRendererOption > rpAsset.m_RendererDataList.Length || p.renderer.hasMultipleDifferentValues)
return false;
var rendererData = selectedRendererOption == -1 ? rpAsset.m_RendererData : rpAsset.m_RendererDataList[selectedRendererOption];
var forwardRendererData = rendererData as UniversalRendererData;
if (forwardRendererData != null && forwardRendererData.postProcessData == null)
return true;
var renderer2DData = rendererData as UnityEngine.Rendering.Universal.Renderer2DData;
return renderer2DData != null && renderer2DData.postProcessData == null;
}
static void DrawerRenderingAntialiasing(UniversalRenderPipelineSerializedCamera p, Editor owner)
{
Rect antiAliasingRect = EditorGUILayout.GetControlRect();
EditorGUI.BeginProperty(antiAliasingRect, Styles.antialiasing, p.antialiasing);
{
EditorGUI.BeginChangeCheck();
int selectedValue = (int)(AntialiasingMode)EditorGUI.EnumPopup(antiAliasingRect, Styles.antialiasing, (AntialiasingMode)p.antialiasing.intValue);
if (EditorGUI.EndChangeCheck())
p.antialiasing.intValue = selectedValue;
}
EditorGUI.EndProperty();
}
static void DrawerRenderingClearDepth(UniversalRenderPipelineSerializedCamera p, Editor owner)
{
EditorGUILayout.PropertyField(p.clearDepth, Styles.clearDepth);
}
static void DrawerRenderingRenderShadows(UniversalRenderPipelineSerializedCamera p, Editor owner)
{
EditorGUILayout.PropertyField(p.renderShadows, Styles.renderingShadows);
}
static void DrawerRenderingSMAAQuality(UniversalRenderPipelineSerializedCamera p, Editor owner)
{
EditorGUILayout.PropertyField(p.antialiasingQuality, Styles.antialiasingQuality);
if (CoreEditorUtils.buildTargets.Contains(GraphicsDeviceType.OpenGLES2))
EditorGUILayout.HelpBox(Styles.SMAANotSupported, MessageType.Warning);
}
static void DrawerRenderingRenderPostProcessing(UniversalRenderPipelineSerializedCamera p, Editor owner)
{
EditorGUILayout.PropertyField(p.renderPostProcessing, Styles.renderPostProcessing);
}
static void DrawerRenderingPriority(UniversalRenderPipelineSerializedCamera p, Editor owner)
{
EditorGUILayout.PropertyField(p.baseCameraSettings.depth, Styles.priority);
}
static void DrawerRenderingDepthTexture(UniversalRenderPipelineSerializedCamera p, Editor owner)
{
EditorGUILayout.PropertyField(p.renderDepth, Styles.requireDepthTexture);
}
static void DrawerRenderingOpaqueTexture(UniversalRenderPipelineSerializedCamera p, Editor owner)
{
EditorGUILayout.PropertyField(p.renderOpaque, Styles.requireOpaqueTexture);
}
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c9bd9b1710724164c8a601affb56d19d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,35 @@
using System.Linq;
using UnityEngine;
namespace UnityEditor.Rendering.Universal
{
static partial class UniversalRenderPipelineCameraUI
{
public partial class Rendering
{
public class Styles
{
public static GUIContent rendererType = EditorGUIUtility.TrTextContent("Renderer", "The series of operations that translates code into visuals. These have different capabilities and performance characteristics.");
public static GUIContent renderPostProcessing = EditorGUIUtility.TrTextContent("Post Processing", "Enable this to make this camera render post-processing effects.");
public static GUIContent antialiasing = EditorGUIUtility.TrTextContent("Anti-aliasing", "The method the camera uses to smooth jagged edges.");
public static GUIContent antialiasingQuality = EditorGUIUtility.TrTextContent("Quality", "The quality level to use for the selected anti-aliasing method.");
public static GUIContent requireDepthTexture = EditorGUIUtility.TrTextContent("Depth Texture", "If this is enabled, the camera builds a screen-space depth texture. Note that generating the texture incurs a performance cost.");
public static GUIContent requireOpaqueTexture = EditorGUIUtility.TrTextContent("Opaque Texture", "If this is enabled, the camera copies the rendered view so it can be accessed at a later stage in the pipeline.");
public static GUIContent clearDepth = EditorGUIUtility.TrTextContent("Clear Depth", "If enabled, depth from the previous camera will be cleared.");
public static GUIContent renderingShadows = EditorGUIUtility.TrTextContent("Render Shadows", "Makes this camera render shadows.");
public static GUIContent priority = EditorGUIUtility.TrTextContent("Priority", "A camera with a higher priority is drawn on top of a camera with a lower priority [ -100, 100 ].");
public static readonly string noRendererError = L10n.Tr("There are no valid Renderers available on the Universal Render Pipeline asset.");
public static readonly string missingRendererWarning = L10n.Tr("The currently selected Renderer is missing from the Universal Render Pipeline asset.");
public static readonly string disabledPostprocessing = L10n.Tr("Post Processing is currently disabled on the current Universal Render Pipeline renderer.");
public static readonly string stopNaNsMessage = L10n.Tr("Stop NaNs has no effect on GLES2 platforms.");
public static readonly string SMAANotSupported = L10n.Tr("Sub-pixel Morphological Anti-Aliasing isn't supported on GLES2 platforms.");
public static readonly string selectRenderPipelineAsset = L10n.Tr("Select Render Pipeline Asset");
}
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0e89e471cecba0d41a66b54909f947cc
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,18 @@
using UnityEngine;
namespace UnityEditor.Rendering.Universal
{
static partial class UniversalRenderPipelineCameraUI
{
public class Styles
{
public static GUIContent cameraType = EditorGUIUtility.TrTextContent("Render Type", "Defines if a camera renders directly to a target or overlays on top of another cameras output. Overlay option is not available when Deferred Render Data is in use.");
public static readonly string pixelPerfectInfo = L10n.Tr("Projection settings have been overriden by the Pixel Perfect Camera.");
// Stack cameras
public static GUIContent stackSettingsText = EditorGUIUtility.TrTextContent("Stack", "The list of overlay cameras assigned to this camera.");
public static GUIContent cameras = EditorGUIUtility.TrTextContent("Cameras", "The list of overlay cameras assigned to this camera.");
public static string inspectorOverlayCameraText = L10n.Tr("Inspector Overlay Camera");
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d86ec93edbc4d5240ab4d8a8be938142
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,148 @@
using System;
using UnityEngine;
using UnityEngine.Rendering.Universal;
namespace UnityEditor.Rendering.Universal
{
class UniversalRenderPipelineSerializedCamera : ISerializedCamera
{
public SerializedObject serializedObject { get; }
public SerializedObject serializedAdditionalDataObject { get; }
public CameraEditor.Settings baseCameraSettings { get; }
// This one is internal in UnityEditor for whatever reason...
public SerializedProperty projectionMatrixMode { get; }
// Common properties
public SerializedProperty dithering { get; }
public SerializedProperty stopNaNs { get; }
public SerializedProperty allowDynamicResolution { get; }
public SerializedProperty volumeLayerMask { get; }
public SerializedProperty clearDepth { get; }
public SerializedProperty antialiasing { get; }
// URP specific properties
public SerializedProperty renderShadows { get; }
public SerializedProperty renderDepth { get; }
public SerializedProperty renderOpaque { get; }
public SerializedProperty renderer { get; }
public SerializedProperty cameraType { get; }
public SerializedProperty cameras { get; set; }
public SerializedProperty volumeTrigger { get; }
public SerializedProperty volumeFrameworkUpdateMode { get; }
public SerializedProperty renderPostProcessing { get; }
public SerializedProperty antialiasingQuality { get; }
#if ENABLE_VR && ENABLE_XR_MODULE
public SerializedProperty allowXRRendering { get; }
#endif
public (Camera camera, UniversalRenderPipelineSerializedCamera serializedCamera) this[int index]
{
get
{
if (index < 0 || index >= numCameras)
throw new ArgumentOutOfRangeException($"{index} is out of bounds [0 - {numCameras}]");
// Return the camera on that index
return (cameras.GetArrayElementAtIndex(index).objectReferenceValue as Camera, cameraSerializedObjects[index]);
}
}
public int numCameras => cameras?.arraySize ?? 0;
UniversalRenderPipelineSerializedCamera[] cameraSerializedObjects { get; set; }
public UniversalAdditionalCameraData[] camerasAdditionalData { get; }
public UniversalRenderPipelineSerializedCamera(SerializedObject serializedObject, CameraEditor.Settings settings = null)
{
this.serializedObject = serializedObject;
projectionMatrixMode = serializedObject.FindProperty("m_projectionMatrixMode");
allowDynamicResolution = serializedObject.FindProperty("m_AllowDynamicResolution");
if (settings == null)
{
baseCameraSettings = new CameraEditor.Settings(serializedObject);
baseCameraSettings.OnEnable();
}
else
{
baseCameraSettings = settings;
}
camerasAdditionalData = CoreEditorUtils
.GetAdditionalData<UniversalAdditionalCameraData>(serializedObject.targetObjects);
serializedAdditionalDataObject = new SerializedObject(camerasAdditionalData);
// Common properties
stopNaNs = serializedAdditionalDataObject.FindProperty("m_StopNaN");
dithering = serializedAdditionalDataObject.FindProperty("m_Dithering");
antialiasing = serializedAdditionalDataObject.FindProperty("m_Antialiasing");
volumeLayerMask = serializedAdditionalDataObject.FindProperty("m_VolumeLayerMask");
clearDepth = serializedAdditionalDataObject.FindProperty("m_ClearDepth");
// URP specific properties
renderShadows = serializedAdditionalDataObject.FindProperty("m_RenderShadows");
renderDepth = serializedAdditionalDataObject.FindProperty("m_RequiresDepthTextureOption");
renderOpaque = serializedAdditionalDataObject.FindProperty("m_RequiresOpaqueTextureOption");
renderer = serializedAdditionalDataObject.FindProperty("m_RendererIndex");
volumeLayerMask = serializedAdditionalDataObject.FindProperty("m_VolumeLayerMask");
volumeTrigger = serializedAdditionalDataObject.FindProperty("m_VolumeTrigger");
volumeFrameworkUpdateMode = serializedAdditionalDataObject.FindProperty("m_VolumeFrameworkUpdateModeOption");
renderPostProcessing = serializedAdditionalDataObject.FindProperty("m_RenderPostProcessing");
antialiasingQuality = serializedAdditionalDataObject.FindProperty("m_AntialiasingQuality");
cameraType = serializedAdditionalDataObject.FindProperty("m_CameraType");
#if ENABLE_VR && ENABLE_XR_MODULE
allowXRRendering = serializedAdditionalDataObject.FindProperty("m_AllowXRRendering");
#endif
}
/// <summary>
/// Updates the internal serialized objects
/// </summary>
public void Update()
{
baseCameraSettings.Update();
serializedObject.Update();
serializedAdditionalDataObject.Update();
for (int i = 0; i < numCameras; ++i)
{
cameraSerializedObjects[i].Update();
}
}
/// <summary>
/// Applies the modified properties to the serialized objects
/// </summary>
public void Apply()
{
baseCameraSettings.ApplyModifiedProperties();
serializedObject.ApplyModifiedProperties();
serializedAdditionalDataObject.ApplyModifiedProperties();
for (int i = 0; i < numCameras; ++i)
{
cameraSerializedObjects[i].Apply();
}
}
/// <summary>
/// Refreshes the serialized properties from the serialized objects
/// </summary>
public void Refresh()
{
var o = new PropertyFetcher<UniversalAdditionalCameraData>(serializedAdditionalDataObject);
cameras = o.Find("m_Cameras");
cameraSerializedObjects = new UniversalRenderPipelineSerializedCamera[numCameras];
for (int i = 0; i < numCameras; ++i)
{
Camera cam = cameras.GetArrayElementAtIndex(i).objectReferenceValue as Camera;
cameraSerializedObjects[i] = new UniversalRenderPipelineSerializedCamera(new SerializedObject(cam));
}
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f5d95b75d9613694da53d274b0ea27c0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: