Согласно этому ответу на форумах Unity , вы можете получить доступ к эффектам громкости следующим образом:
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);
}
}
}
}