浏览代码

Coupling HDCamera and HDAdditionalCameraData for reset/remove

/main
sebastienlagarde 6 年前
当前提交
b6c5c9e7
共有 2 个文件被更改,包括 58 次插入10 次删除
  1. 37
      com.unity.render-pipelines.high-definition/HDRP/Camera/HDAdditionalCameraData.cs
  2. 31
      com.unity.render-pipelines.high-definition/HDRP/Editor/Camera/HDCameraEditor.cs

37
com.unity.render-pipelines.high-definition/HDRP/Camera/HDAdditionalCameraData.cs


using UnityEngine.Serialization;
using UnityEngine.Assertions;
namespace UnityEngine.Experimental.Rendering.HDPipeline
{

None
};
public ClearColorMode clearColorMode = ClearColorMode.Sky;
public ClearColorMode clearColorMode;
public Color backgroundColorHDR = new Color(0.025f, 0.07f, 0.19f, 0.0f);
public bool clearDepth = true;
public Color backgroundColorHDR;
public bool clearDepth;
public LayerMask volumeLayerMask = -1;
public LayerMask volumeLayerMask;
public float aperture = 8f;
public float shutterSpeed = 1f / 200f;
public float iso = 400f;
public float aperture;
public float shutterSpeed;
public float iso;
// To be able to turn on/off FrameSettings properties at runtime for debugging purpose without affecting the original one
// we create a runtime copy (m_ActiveFrameSettings that is used, and any parametrization is done on serialized frameSettings)

// When we are a preview, there is no way inside Unity to make a disctinctoin between camera preview and material preview.
// This property allow to say that we are an editor camera preview when the type is preview.
public bool isEditorCameraPreview { get; set; }
private void Awake()
{
Init();
}
public void Reset()
{
Init();
}
private void Init()
{
clearColorMode = ClearColorMode.Sky;
backgroundColorHDR = new Color(0.025f, 0.07f, 0.19f, 0.0f);
clearDepth = true;
renderingPath = RenderingPath.Default;
volumeLayerMask = -1;
aperture = 8f;
shutterSpeed = 1f / 200f;
iso = 400f;
}
// This is the function use outside to access FrameSettings. It return the current state of FrameSettings for the camera
// taking into account the customization via the debug menu

31
com.unity.render-pipelines.high-definition/HDRP/Editor/Camera/HDCameraEditor.cs


[CanEditMultipleObjects]
partial class HDCameraEditor : Editor
{
[MenuItem("CONTEXT/Camera/Remove HD Camera", false, 0)]
[MenuItem("CONTEXT/Camera/Remove Component", false, 0)]
Camera camera = go.GetComponent<Camera>();
HDAdditionalCameraData cameraAdditionalData = go.GetComponent<HDAdditionalCameraData>();
Assert.IsNotNull(camera);
Assert.IsNotNull(cameraAdditionalData);
Undo.DestroyObjectImmediate(go.GetComponent<Camera>());
Undo.DestroyObjectImmediate(go.GetComponent<HDAdditionalCameraData>());
Undo.DestroyObjectImmediate(camera);
Undo.DestroyObjectImmediate(cameraAdditionalData);
}
[MenuItem("CONTEXT/Camera/Reset", false, 0)]
static void ResetLight(MenuCommand menuCommand)
{
GameObject go = ((Camera)menuCommand.context).gameObject;
Assert.IsNotNull(go);
Camera camera = go.GetComponent<Camera>();
HDAdditionalCameraData cameraAdditionalData = go.GetComponent<HDAdditionalCameraData>();
Assert.IsNotNull(camera);
Assert.IsNotNull(cameraAdditionalData);
Undo.SetCurrentGroupName("Reset HD Camera");
Undo.RecordObjects(new UnityEngine.Object[] { camera, cameraAdditionalData }, "Reset HD Camera");
camera.Reset();
cameraAdditionalData.Reset();
}
SerializedHDCamera m_SerializedCamera;

正在加载...
取消
保存