C# 如何通过Unity中的脚本访问卷后处理效果

C# 如何通过Unity中的脚本访问卷后处理效果,c#,unity3d,C#,Unity3d,因此,我目前正在使用HDRP制作一个3D游戏,为了调整游戏的亮度,我使用组件颜色调整(查看附件图像),并在那里更改颜色过滤器的强度(单击“HDR”选项后显示强度)。所以我的问题是:如何在C#脚本中访问这些信息?可能吗?如果可能的话,我会非常高兴,如果你,读这篇文章的人能告诉我 提前谢谢 根据,您可以访问以下音量效果: using UnityEngine; using UnityEngine.Rendering; using UnityEngine.Experimental.Rendering.H

因此,我目前正在使用HDRP制作一个3D游戏,为了调整游戏的亮度,我使用组件颜色调整(查看附件图像),并在那里更改颜色过滤器的强度(单击“HDR”选项后显示强度)。所以我的问题是:如何在C#脚本中访问这些信息?可能吗?如果可能的话,我会非常高兴,如果你,读这篇文章的人能告诉我

提前谢谢

根据,您可以访问以下音量效果:

using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Experimental.Rendering.HDPipeline;
public class AffectDepthOfField : MonoBehaviour
{
    public bool spherecast = true;
    public Transform mainCamera;
    RaycastHit hit;

    DepthOfField dofComponent;

    void Start()
    {
        Volume volume = gameObject.GetComponent<Volume>();
        DepthOfField tmp;
        if (volume.profile.TryGet<DepthOfField>(out tmp))
        {
            dofComponent = tmp;
        }
    }
    void Update()
    {
        if (spherecast)
        {
            if (Physics.SphereCast(mainCamera.position, 0.1f, mainCamera.forward, out hit, 10f))
            {
                dofComponent.nearFocusStart = new MinFloatParameter(1f, 0f, true);
                dofComponent.nearFocusEnd = new MinFloatParameter(1f, 0f, true);
                dofComponent.farFocusStart = new MinFloatParameter(1f, 0f, true);
                dofComponent.farFocusEnd = new MinFloatParameter(1f, 0f, true);
            }
        }
    }
}
使用UnityEngine;
使用UnityEngine.Rendering;
使用UnityEngine.Experimental.Rendering.HDPipeline;
受公众阶级影响的领域:单一行为
{
public bool spherecast=true;
公共摄像机;
雷卡斯特击中;
DepthOfField Dof组件;
void Start()
{
Volume=gameObject.GetComponent();
高级管理人员;
if(卷配置文件测试集(输出tmp))
{
dofComponent=tmp;
}
}
无效更新()
{
if(spherecast)
{
if(物理球卡斯特(主摄像机位置,0.1f,主摄像机向前,命中率,10f))
{
dofComponent.nearFocusStart=新的MinFloatParameter(1f,0f,true);
dofComponent.nearFocusEnd=新的MinFloatParameter(1f,0f,true);
dofComponent.farFocusStart=新的MinFloatParameter(1f,0f,true);
dofComponent.farFocusEnd=新的MinFloatParameter(1f,0f,true);
}
}
}
}

您可以将其放在一个单独的子游戏对象中,如果您只想启用/禁用它,则可以将其启用或禁用。(如果这不是您的意图,请忽略此项)。

您是否尝试过
GetComponent().ColorFilter
?这不起作用。只是给了我一些错误,比如“找不到'colorAdjusts'。我在这方面取得了一些进展,比如像这样引用颜色调整:
colorAdjusts\u colorAdjusts=gameObject.GetComponent()
然后继续,通过写入
\u colorAdjustments.colorFilter
来更改颜色过滤器的强度,然后我卡住了。你知道如何从这里改变“HDR颜色”的强度吗?