So I’m trying to change the radius of a blur in runtime that is on a custom pass. the float i am trying to edit is public by the way.
i am using slightblur from this code.
So I’m trying to change the radius of a blur in runtime that is on a custom pass. the float i am trying to edit is public by the way.
i am using slightblur from this code.
I solved it.
this is what i basically did CustomPassVolume customPassVolume = FindObjectOfType();
Sorry for necro and my English.
Slight Blur pass from git inherits from CustomPass class, so you can use casting (I believe this is how you call this method, Idk I’m not a coder) to access public variables of inherited class.
Example code:
public class VolumeBlurController : MonoBehaviour
{
[SerializeField] private float _speed;
// CustomPassVolume contains all CustomPasses you assign to it
[SerializeField]private CustomPassVolume _customPassVolume;
private CustomPass _customPass;
private SlightBlur _blurPass;
private float _targetValue;
void Start()
{
//Access specific custom pass in the volume's list
_customPass = _customPassVolume.customPasses[0];
//Casting
_blurPass = _customPass as SlightBlur;
}
void Update()
{
// "radius" - public variable of blur pass
_blurPass.radius = Mathf.Lerp(_blurPass.radius, _targetValue, 1 - Mathf.Exp(-_speed * Time.deltaTime));
}
public void SetTargetMin()
{
_targetValue = 0f;
}
public void SetTargetMax()
{
_targetValue = 16f;
}
void OnEnable()
{
DraftActions.BlurMin += SetTargetMin;
DraftActions.BlurMax += SetTargetMax;
}
void OnDisable()
{
DraftActions.BlurMin -= SetTargetMin;
DraftActions.BlurMax -= SetTargetMax;
}
}