This commit is contained in:
2026-01-23 12:59:14 +00:00
parent 9432d2d776
commit 3c08b15c9e
6 changed files with 107 additions and 11 deletions

35
Assets/tmp.cs Normal file
View File

@@ -0,0 +1,35 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class tmp : MonoBehaviour
{
public Camera cam;
void Update()
{
float targetAspect = 16f / 9f;
float windowAspect = (float)Screen.width / Screen.height;
float scale = windowAspect / targetAspect;
if (scale < 1f)
{
cam.rect = new Rect(
0,
(1f - scale) / 2f,
1f,
scale
);
}
else
{
float width = 1f / scale;
cam.rect = new Rect(
(1f - width) / 2f,
0,
width,
1f
);
}
}
}