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.high-definition/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed AxF handling of roughness for Blinn-Phong type materials
- Fixed AxF UI errors when surface type is switched to transparent
- Fixed a serialization issue, preventing quality level parameters to undo/redo and update scene view on change.
- Fixed an exception occuring when a camera doesn't have an HDAdditionalCameraData (1254383).

### Changed
- Improve MIP selection for decals on Transparents
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using UnityEngine;
using UnityEngine.Assertions;
using UnityEngine.Rendering;
using UnityEngine.Rendering.HighDefinition;
using System.Collections.Generic;
using System.Linq;
Expand Down Expand Up @@ -89,14 +90,24 @@ public void RemoveComponent(Camera camera, IEnumerable<Component> dependencies)
[MenuItem("CONTEXT/Camera/Reset", false, 0)]
static void ResetCamera(MenuCommand menuCommand)
{
GameObject go = ((Camera)menuCommand.context).gameObject;
// Grab the current HDRP asset, we should not be executing this code if HDRP is null
var hdrp = (RenderPipelineManager.currentPipeline as HDRenderPipeline);
if (hdrp == null)
return;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can have a better workflow here.

If there is HDRP package but no HDAdditionalCameraData sibling, we do nothing with your solution. But basically the user want here to reset its camera that is not a HDRP one no?

Also if you have an HDAdditionalCameraData but the current SRP is not the HDRP one, a built-in Camera should be displayed. But this camera Reset contextual menu command should still perform the reset.

So I think, if I not mistaken that we should call camera.Reset(); before returning.


GameObject go = ((Camera)menuCommand.context).gameObject;
Assert.IsNotNull(go);

Camera camera = go.GetComponent<Camera>();
HDAdditionalCameraData cameraAdditionalData = go.GetComponent<HDAdditionalCameraData>();

Assert.IsNotNull(camera);

// Try to grab the HDAdditionalCameraData component, it is possible that the component is null of the camera was created without an asset assigned and the inspector
// was kept on while assigning the asset and then triggering the reset.
HDAdditionalCameraData cameraAdditionalData;
if ((!go.TryGetComponent<HDAdditionalCameraData>(out cameraAdditionalData)))
{
cameraAdditionalData = go.AddComponent<HDAdditionalCameraData>();
}
Assert.IsNotNull(cameraAdditionalData);

Undo.SetCurrentGroupName("Reset HD Camera");
Expand Down