using System;
using UnityEngine;

public class FadeInAndFadeOutOnGUI : MonoBehaviour
{
	public void Awake()
	{
		if (this.tex_ == null)
		{
			this.tex_ = new Texture2D(32, 32, TextureFormat.ARGB32, false);
			for (int i = 0; i < 32; i++)
			{
				for (int j = 0; j < 32; j++)
				{
					this.tex_.SetPixel(i, j, Color.white);
				}
			}
			this.tex_.Apply();
		}
		this.Update();
	}

	public void OnDestroy()
	{
		if (this.tex_ != null)
		{
			UnityEngine.Object.DestroyImmediate(this.tex_);
		}
	}

	public void Update()
	{
	}

	public void OnGUI()
	{
		if (this.tex_ != null && this.intensity < 1f)
		{
			Color color = GUI.color;
			GUI.color = new Color(this.color.r, this.color.g, this.color.b, 1f - this.intensity);
			GUI.DrawTexture(this.render_rect_, this.tex_);
			GUI.color = color;
		}
	}

	public bool UpdateRenderRect()
	{
		if (this.window_size_.x != (float)Screen.width || this.window_size_.y != (float)Screen.height)
		{
			this.window_size_.x = (float)Screen.width;
			this.window_size_.y = (float)Screen.height;
			return true;
		}
		return false;
	}

	public float intensity = 1f;

	public Color color = Color.black;

	private Texture2D tex_;

	private Rect render_rect_ = new Rect(0f, 0f, 8192f, 8192f);

	private Vector2 window_size_ = Vector2.zero;
}
