如何在Unity中使用代码淡化色差?

问题描述 投票:-2回答:1

我正在尝试将一个由按键触发的色差效果淡入淡出,但不知道从哪里开始。

我需要它在x时间段内淡入淡出,如果你在淡入淡出的过程中把手指从键上移开,它就会从那里淡出。

似乎很少有通过代码控制后期处理的文档.请推荐任何资源。

c# unity3d effects post-processing
1个回答
0
投票

我猜你使用的是后期处理包。这里有一个很好的资源,可以得到一些关于如何使用它的信息。https:/docs.unity3d.comPackagescom.unity.postprocessing@2.1manualManipulating-the-Stack.html

使用本系统操作后期处理(pp)效果的最简单方法是覆盖pp配置文件的设置。

只需像在场景中引用其他资产一样引用配置文件,抓住ChromaticAberration设置并覆盖设置。

public PostProcessProfile profile;
private ChromaticAberration ca;
// Start is called before the first frame update
void Start()
{
    ca = profile.GetSetting<ChromaticAberration>();
}

// Update is called once per frame
void Update()
{
    ca.intensity.Override(Mathf.Sin(Time.frameCount * 0.1f));
}

像这样: 要做渐变,我建议你使用一个Tweening库 就像我链接的例子一样 DoTween是伟大的。如果你不想这样做,你总是可以创建自己的coroutines和动画行为。

© www.soinside.com 2019 - 2024. All rights reserved.