using System;
using UnityEngine;

public class PixelPerfect : MonoBehaviour
{
	private void Awake()
	{
		this.my_camera_ = base.GetComponent<Camera>();
		NDebug.AssertNull(this.TargetMesh != null && this.my_camera_ != null);
	}

	private void Start()
	{
		this.my_camera_.orthographic = true;
		this.UpdateTargetSize();
	}

	private void LateUpdate()
	{
		this.UpdateTargetSize();
	}

	private void UpdateTargetSize()
	{
		Vector3 localScale = this.TargetMesh.transform.localScale;
		if (this.render_size_.x != localScale.x || this.render_size_.y != localScale.z)
		{
			this.render_size_.x = localScale.x;
			this.render_size_.y = localScale.z;
			this.my_camera_.orthographicSize = this.render_size_.y / 2f;
		}
	}

	[SerializeField]
	private MeshRenderer TargetMesh;

	private Camera my_camera_;

	private Vector2 render_size_;
}
