12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- using System;
- using UnityEngine;
- using UnityEngine.UI;
- [RequireComponent(typeof(RawImage))]
- [RequireComponent(typeof(Mask))]
- public class FadeUI : MonoBehaviour, IFade
- {
- public float Range
- {
- get
- {
- return this.cutoutRange;
- }
- set
- {
- this.cutoutRange = value;
- this.UpdateMaskCutout(this.cutoutRange);
- }
- }
- private void UpdateMaskCutout(float range)
- {
- this.mat.SetFloat("_Range", range);
- Graphics.Blit(this.texture, this.rt, this.mat);
- Mask component = base.GetComponent<Mask>();
- component.enabled = false;
- component.enabled = true;
- }
- [SerializeField]
- [Range(0f, 1f)]
- private float cutoutRange;
- [SerializeField]
- private Material mat;
- [SerializeField]
- private RenderTexture rt;
- [SerializeField]
- private Texture texture;
- }
|