我似乎找不到一种方法来从代码中轻松地更改统一-effect堆栈中的“布鲁姆”PostProcessing的颜色。以下是我尝试过的,但没有效果的:
var postProcessVolume = GameObject.FindObjectOfType<UnityEngine.Rendering.PostProcessing.PostProcessVolume>();
UnityEngine.Rendering.PostProcessing.Bloom bloom = postProcessVolume.profile.GetSetting<UnityEngine.Rendering.PostProcessing.Bloom>();
var colorParameter = new UnityEngine.Rendering.PostProcessing.ColorParameter();
colorParameter.value = mainPlayer.GenerateRandomColour();
bloom.color = colorParameter;
bloom.color.value = colorParameter.value;
bloom.enabled.value = true; 代码编译和运行良好,但没有视觉效果。我看过几篇关于这方面的文章,包括这里和
这里。我尝试了在这些链接中找到的所有方法,但都没有成功。
难道没有一种简单的方法从统一代码中改变“-effect”的颜色吗?
发布于 2020-05-10 04:21:24
使用覆盖(值)方法:
Bloom bloom = postProcessVolume.profile.GetSetting<UnityEngine.Rendering.PostProcessing.Bloom>();
var colorParameter = new UnityEngine.Rendering.PostProcessing.ColorParameter();
colorParameter.value = Color.red;
bloom.color.Override(colorParameter);https://docs.unity3d.com/Packages/com.unity.postprocessing@2.0/manual/Manipulating-the-Stack.html
发布于 2022-03-20 23:39:22
不确定是否有人需要这个,但我做了一些与URP类似的事情。
private Vignette GetVignette()
{
for (int i = 0; i < volume.profile.components.Count; i++)
{
if(volume.profile.components[i] is Vignette)
{
return (Vignette)volume.profile.components[i];
}
}
return null;
}https://stackoverflow.com/questions/61706589
复制相似问题