summaryrefslogtreecommitdiff
path: root/Client/Assembly-CSharp/AspectSize.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Client/Assembly-CSharp/AspectSize.cs')
-rw-r--r--Client/Assembly-CSharp/AspectSize.cs32
1 files changed, 32 insertions, 0 deletions
diff --git a/Client/Assembly-CSharp/AspectSize.cs b/Client/Assembly-CSharp/AspectSize.cs
new file mode 100644
index 0000000..c0c8fe8
--- /dev/null
+++ b/Client/Assembly-CSharp/AspectSize.cs
@@ -0,0 +1,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);
+ }
+}