using System;
using UnityEngine;
using UnityEngine.UI;

[RequireComponent(typeof(RawImage))]
[RequireComponent(typeof(Mask))]
public class UGuiRule : Graphic, IFade
{
	protected override void Start()
	{
		base.Start();
		this.UpdateMaskTexture(this.maskTexture);
	}

	public void UpdateMaskTexture(Texture texture)
	{
		this.material.SetTexture("_MaskTex", texture);
		this.material.SetColor("_Color", this.color);
	}

	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);
		Mask component = base.GetComponent<Mask>();
		component.enabled = false;
		component.enabled = true;
	}

	[SerializeField]
	private Texture maskTexture;

	[SerializeField]
	[Range(0f, 1f)]
	private float cutoutRange;

	[SerializeField]
	private Material mat;

	[SerializeField]
	private RenderTexture rt;

	[SerializeField]
	private Texture texture;
}
