玉盘珍馐值万钱 缝缝补补又三天 长音已改逾卅遍

This commit is contained in:
FloatGaming
2025-12-21 04:16:10 +08:00
parent a7d8d71d10
commit 1ab80e504e
93 changed files with 130237 additions and 34637 deletions
+55
View File
@@ -0,0 +1,55 @@
using UnityEngine;
[ExecuteAlways]
[RequireComponent(typeof(Camera))]
public class CameraLetterbox : MonoBehaviour
{
public float targetAspect = 16f / 9f;
private int lastWidth;
private int lastHeight;
void OnEnable()
{
ApplyLetterbox();
lastWidth = Screen.width;
lastHeight = Screen.height;
}
void Update()
{
if (Screen.width != lastWidth || Screen.height != lastHeight)
{
ApplyLetterbox();
lastWidth = Screen.width;
lastHeight = Screen.height;
}
}
void ApplyLetterbox()
{
Camera cam = GetComponent<Camera>();
float screenAspect = (float)Screen.width / Screen.height;
float scaleHeight = screenAspect / targetAspect;
if (scaleHeight < 1.0f)
{
cam.rect = new Rect(
0,
(1f - scaleHeight) / 2f,
1,
scaleHeight
);
}
else
{
float scaleWidth = 1f / scaleHeight;
cam.rect = new Rect(
(1f - scaleWidth) / 2f,
0,
scaleWidth,
1
);
}
}
}