bad-piggies-0.1.3-porting/Assets/Scripts/Assembly-CSharp/GUITextureAspectFix.cs
2024-02-24 22:40:44 -05:00

27 lines
569 B
C#

using UnityEngine;
public class GUITextureAspectFix : MonoBehaviour
{
protected Vector3 m_origScale;
public void Awake()
{
m_origScale = base.transform.localScale;
FixAspect();
}
public void LateUpdate()
{
FixAspect();
}
private void FixAspect()
{
GUITexture component = GetComponent<GUITexture>();
Vector3 origScale = m_origScale;
float num = (float)Screen.width / (float)Screen.height;
float num2 = (float)component.texture.width / (float)component.texture.height;
origScale.y *= num / num2;
base.transform.localScale = origScale;
}
}