Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions com.unity.render-pipelines.universal/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
## [13.1.1] - 2021-10-04

### Added
- Added a warning when using Pixel Perfect Camera in SRP without a 2D Renderer and exposed RenderPipelineConverter for 2D Pixel Perfect to URP converter.
- Added Depth Texture setting for Overlay Camera.
- Added Depth Priming support for Vulkan with MSAA.
- Added Shadows and Additional Lights off variants stripping.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ private class Style
public GUIContent currentPixelRatio = new GUIContent("Current Pixel Ratio", "Ratio of the rendered Sprites compared to their original size.");
public GUIContent runInEditMode = new GUIContent("Run In Edit Mode", "Enable this to preview Camera setting changes in Edit Mode. This will cause constant changes to the Scene while active.");
public const string cameraStackingWarning = "Pixel Perfect Camera won't function properly if stacked with another camera.";
public const string nonRenderer2DError = "Pixel Perfect Camera requires a camera using a 2D Renderer.";
public const string nonRenderer2DWarning = "URP Pixel Perfect Camera requires a camera using a 2D Renderer. Some features, such as Upscale Render Texture, are not supported with other Renderers.";
public const string nonRenderer2DError = "URP Pixel Perfect Camera requires a camera using a 2D Renderer.";

public GUIStyle centeredLabel;

Expand Down Expand Up @@ -57,11 +58,23 @@ private void LazyInit()
m_CurrentPixelRatioValue = new GUIContent();
}

bool UsingRenderer2D()
UniversalAdditionalCameraData GetCameraData()
{
PixelPerfectCamera obj = target as PixelPerfectCamera;
UniversalAdditionalCameraData cameraData = null;
obj?.TryGetComponent(out cameraData);
return cameraData;
}

bool UsingSRP()
{
var cameraData = GetCameraData();
return cameraData?.scriptableRenderer != null;
}

bool UsingRenderer2D()
{
var cameraData = GetCameraData();

if (cameraData != null)
{
Expand All @@ -77,11 +90,9 @@ void CheckForCameraStacking()
{
m_CameraStacking = false;

PixelPerfectCamera obj = target as PixelPerfectCamera;
UniversalAdditionalCameraData cameraData = null;
obj?.TryGetComponent(out cameraData);
var cameraData = GetCameraData();

if (cameraData == null)
if (cameraData == null || cameraData.scriptableRenderer == null)
return;

if (cameraData.renderType == CameraRenderType.Base)
Expand Down Expand Up @@ -124,11 +135,16 @@ public override void OnInspectorGUI()
{
LazyInit();

if (!UsingRenderer2D())
if (!UsingSRP())
{
EditorGUILayout.HelpBox(Style.nonRenderer2DError, MessageType.Error);
return;
}
else if (!UsingRenderer2D())
{
EditorGUILayout.HelpBox(Style.nonRenderer2DWarning, MessageType.Warning);
EditorGUILayout.Space();
}

float originalLabelWidth = EditorGUIUtility.labelWidth;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Runtime.CompilerServices;

[assembly: InternalsVisibleTo("PPv2URPConverters")]
[assembly: InternalsVisibleTo("Unity.2D.PixelPerfect.Editor")]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which internal API do you need access?

Copy link
Contributor Author

@kennytann kennytann Nov 25, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The RenderPipelineConverter class. Made a new converter for 2D to URP Pixel Perfect Camera it so it will be a part of the Upgrade 2D (URP) Assets in the Render Pipeline Converter. See https://github.cds.internal.unity3d.com/unity/2d/pull/1514 (not sure if you have access)

namespace UnityEditor.Rendering.Universal.Converters
{
// Might need to change this name before making it public
Expand Down