summaryrefslogtreecommitdiff
path: root/Client/Assembly-CSharp/AspectSize.cs
blob: c0c8fe8e72bf07a6a0b00dbff4f5b05a78c0de2b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using System;
using UnityEngine;

public class AspectSize : MonoBehaviour
{
	public Sprite Background;

	public SpriteRenderer Renderer;

	public float PercentWidth = 0.95f;

	public void OnEnable()
	{
		Camera main = Camera.main;
		float num = main.orthographicSize * main.aspect;
		float num2 = (this.Background ? this.Background : this.Renderer.sprite).bounds.size.x / 2f;
		float num3 = num / num2 * this.PercentWidth;
		if (num3 < 1f)
		{
			base.transform.localScale = new Vector3(num3, num3, num3);
		}
	}

	public static float CalculateSize(Vector3 parentPos, Sprite sprite)
	{
		Camera main = Camera.main;
		float num = main.orthographicSize * main.aspect + parentPos.x;
		float x = sprite.bounds.size.x;
		float b = num / x * 0.98f;
		return Mathf.Min(1f, b);
	}
}