This commit is contained in:
corn
2026-06-07 22:59:32 +08:00
commit a62ff7379b
7171 changed files with 10015624 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: b77513f8238ead942839e555b41e7005
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,50 @@
using UnityEngine;
[ExecuteAlways]
public class SafeAreaController : MonoBehaviour
{
RectTransform Panel;
Rect LastSafeArea = new Rect(0, 0, 0, 0);
void Awake()
{
Panel = GetComponent<RectTransform>();
Refresh();
}
void Update()
{
// Refresh();
}
void Refresh()
{
Rect safeArea = GetSafeArea();
if (safeArea != LastSafeArea)
ApplySafeArea(safeArea);
}
public Rect GetSafeArea()
{
return Screen.safeArea;
}
void ApplySafeArea(Rect r)
{
LastSafeArea = r;
// Convert safe area rectangle from absolute pixels to normalised anchor coordinates
Vector2 anchorMin = r.position;
Vector2 anchorMax = r.position + r.size;
anchorMin.x /= Screen.width;
anchorMin.y /= Screen.height;
anchorMax.x /= Screen.width;
anchorMax.y /= Screen.height;
Panel.anchorMin = anchorMin;
Panel.anchorMax = anchorMax;
// Debug.LogFormat("New safe area applied to {0}: x={1}, y={2}, w={3}, h={4} on full extents w={5}, h={6}",
// name, r.x, r.y, r.width, r.height, Screen.width, Screen.height);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 795ac1b8089e2df4eb37c4c260322d7d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: