NLDClient-yudde/ProjectNLD/Assets/Code/Scripts/Gameplay/Utils/ShadowEx.cs

34 lines
1.0 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;
namespace Code.Scripts.Gameplay.Utils
{
public static class ShadowEx
{
public static void SetShadowDistance(float setDistance)
{
var urpAsset = UniversalRenderPipeline.asset;
if (urpAsset == null)
{
DebugUtil.LogError("无法获取URP设置资源无法设置阴影距离");
}
else
{
DebugUtil.Log(urpAsset.name);
DebugUtil.Log("old shadow distance: " + urpAsset.shadowDistance);
urpAsset.shadowDistance = setDistance;
DebugUtil.Log("new shadow distance: " + urpAsset.shadowDistance);
// 更新 URP 的 Asset 实例
GraphicsSettings.renderPipelineAsset = urpAsset;
}
// 通过旧的也设置一下
QualitySettings.shadowDistance = setDistance;
}
}
}