【发布时间】:2020-08-11 16:20:56
【问题描述】:
在我相机上的编辑器中,我添加了两个组件:后期处理层和后期处理体积 在第一个组件上,我将图层更改为我添加的图层 PostProcessing 在第二个组件上,我将 Is Global 设置为 true,并为现在的景深添加了一个效果
现在我想通过脚本更改和设置景深焦距的值。 所以我创建了一个新脚本:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering.PostProcessing;
public class PostprocessingEffects : MonoBehaviour
{
private PostProcessVolume postProcessVolume;
private DepthOfField depthOfField;
void Start()
{
postProcessVolume = GetComponent<PostProcessVolume>();
postProcessVolume.profile.TryGetSettings(out PostProcessEffectSettings depthOfFieldSettings);
depthOfField.focalLength.value = 1f;
}
}
我在线上遇到错误:
postProcessVolume.profile.TryGetSettings(out depthOfField);
在 TryGetSettings 上,错误是:
类型“PostprocessingEffects”不能用作泛型类型或方法“PostProcessProfile.TryGetSettings(out T)”中的类型参数“T”。没有从“PostprocessingEffects”到“UnityEngine.Rendering.PostProcessing.PostProcessEffectSettings”的隐式引用转换。
也试过了:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering.PostProcessing;
public class PostprocessingEffects : MonoBehaviour
{
private PostProcessVolume postProcessVolume;
private DepthOfField depthOfField;
void Start()
{
postProcessVolume = GetComponent<PostProcessVolume>();
postProcessVolume.profile.TryGetSettings(out DepthOfField depthOfField);
depthOfField.focalLength.value = 1f;
}
}
【问题讨论】:
标签: c# unity3d post-processing