float m_Version = 1.0f ;
#pragma warning restore 414
Camera m_camera ;
// This struct allow to add specialized path in HDRenderPipeline (can be use to render mini map or planar reflection etc...)
// A rendering path is the list of rendering pass that will be executed at runtime and depends on the associated FrameSettings
// Default is the default rendering path define by the HDRendeRPipelineAsset FrameSettings.
[FormerlySerializedAs("serializedFrameSettings")]
FrameSettings m_FrameSettings = new FrameSettings ( ) ; // Serialize frameSettings
// Not serialized, not visible
// Not serialized, visible only in the debug windows
bool m_frameSettingsIsDirty = true ;
// Use for debug windows
// When camera name change we need to update the name in DebugWindows.
// This is the purpose of this class
bool m_IsDebugRegistered = false ;
string m_CameraRegisterName ;
// 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
bool m_IsDebugRegistered = false ;
Camera m_camera ;
string m_CameraRegisterName ;
// This function is call at the beginning of camera loop in HDRenderPipeline.Render()
// It allow to correctly init the m_FrameSettingsRuntime to use.
// If the camera use defaultFrameSettings it must be copied in m_FrameSettingsRuntime
// otherwise it is the serialized m_FrameSettings that are used
// This is required so each camera have its own debug settings even if they all use the RenderingPath.Default path
// and important at Runtime as Default Camera from Scene Preview doesn't exist
// assetFrameSettingsIsDirty is the current dirty frame settings state of HDRenderPipelineAsset
// if it is dirty and camera use RenderingPath.Default, we need to update it
// defaultFrameSettings are the settings store in the HDRenderPipelineAsset
public void UpdateDirtyFrameSettings ( bool assetFrameSettingsIsDirty , FrameSettings defaultFrameSettings )
{
if ( m_frameSettingsIsDirty | | assetFrameSettingsIsDirty )
{
// We do a copy of the settings to those effectively used
if ( renderingPath = = RenderingPath . Default )
{
defaultFrameSettings . CopyTo ( m_FrameSettingsRuntime ) ;
}
else
{
m_FrameSettings . CopyTo ( m_FrameSettingsRuntime ) ;
}
m_frameSettingsIsDirty = false ;
}
}
FrameSettings . RegisterDebug ( m_camera . name , GetFrameSettings ( ) ) ;
// Note that we register m_FrameSettingsRuntime, so manipulating it in the Debug windows
// doesn't affect the serialized version
if ( m_camera . cameraType ! = CameraType . Preview )
{
FrameSettings . RegisterDebug ( m_camera . name , GetFrameSettings ( ) ) ;
}
m_CameraRegisterName = m_camera . name ;
m_IsDebugRegistered = true ;
}
{
if ( m_IsDebugRegistered )
{
FrameSettings . UnRegisterDebug ( m_CameraRegisterName ) ;
if ( m_camera . cameraType ! = CameraType . Preview )
{
FrameSettings . UnRegisterDebug ( m_CameraRegisterName ) ;
}
m_IsDebugRegistered = false ;
}
}
m_camera = GetComponent < Camera > ( ) ;
m_camera . allowHDR = false ;
m_FrameSettings . CopyTo ( m_FrameSettingsRuntime ) ;
// Tag as dirty so frameSettings are correctly initialize at next HDRenderPipeline.Render() call
m_frameSettingsIsDirty = true ;
RegisterDebug ( ) ;
}
// We need to detect name change in the editor and update debug windows accordingly
#if UNITY_EDITOR
if ( m_camera . name ! = m_CameraRegisterName )
{
public void OnAfterDeserialize ( )
{
// We do a copy of the settings to those effectively used
m_FrameSettings . CopyTo ( m_FrameSettingsRuntime ) ;
// This is call on load or when this settings are change.
// When FrameSettings are manipulated or RenderPath change we reset them to reflect the change, discarding all the Debug Windows change.
// Tag as dirty so frameSettings are correctly initialize at next HDRenderPipeline.Render() call
m_frameSettingsIsDirty = true ;
}
}
}