您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

56 行
1.5 KiB

namespace UnityEngine.XR.ARFoundation.LWRPSupport
{
public class LWRPBackgroundRenderer : ARFoundationBackgroundRenderer
{
CameraClearFlags m_SavedClearFlags;
LWRPBeforeCameraRender m_LWRPBeforeCameraRender;
protected override bool EnableARBackgroundRendering()
{
if (m_BackgroundMaterial == null)
return false;
camera = m_Camera ? m_Camera : Camera.main;
if (camera == null)
return false;
// Clear flags
m_SavedClearFlags = camera.clearFlags;
camera.clearFlags = CameraClearFlags.Depth;
if (m_LWRPBeforeCameraRender == null)
{
m_LWRPBeforeCameraRender = camera.gameObject.GetComponent<LWRPBeforeCameraRender>();
}
m_LWRPBeforeCameraRender.blitMaterial = m_BackgroundMaterial;
return true;
}
protected override void DisableARBackgroundRendering()
{
if (m_BackgroundMaterial == null)
return;
camera = m_Camera ? m_Camera : Camera.main;
if (camera == null)
return;
camera.clearFlags = m_SavedClearFlags;
if (m_LWRPBeforeCameraRender != null)
{
m_LWRPBeforeCameraRender.blitMaterial = null;
m_LWRPBeforeCameraRender = null;
}
}
}
}