rabidus-test/Assets/Plugins/QFSW/Quantum Console/Source/Scripts/UI/BlurShaderController.cs

24 lines
750 B
C#
Raw Normal View History

2023-08-22 15:41:12 +03:00
using UnityEngine;
namespace QFSW.QC.UI
{
[ExecuteInEditMode]
public class BlurShaderController : MonoBehaviour
{
[SerializeField] private Material _blurMaterial = null;
[SerializeField] private float _blurRadius = 1f;
[SerializeField] private Vector2 _referenceResolution = new Vector2(1920, 1080);
private void LateUpdate()
{
if (_blurMaterial)
{
Vector2 resolution = new Vector2(Screen.width, Screen.height);
float correction = resolution.y / _referenceResolution.y;
_blurMaterial.SetFloat("_Radius", _blurRadius);
_blurMaterial.SetFloat("_BlurMultiplier", correction);
}
}
}
}