From e9ea621b93fbb58d9edfca8375918791637bbd52 Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 30 Dec 2020 20:59:04 +0800 Subject: +init --- Client/Assembly-CSharp/AspectSize.cs | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 Client/Assembly-CSharp/AspectSize.cs (limited to 'Client/Assembly-CSharp/AspectSize.cs') 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); + } +} -- cgit v1.1-26-g67d0