fix: 모바일 기기의 SafeArea에 맞춰 화면 비율 고정 로직 적용
This commit is contained in:
32
Gameton-06/Assets/Gameton/Scripts/Common/RectHelper.cs
Normal file
32
Gameton-06/Assets/Gameton/Scripts/Common/RectHelper.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TON
|
||||
{
|
||||
public class RectHelper : MonoBehaviour
|
||||
{
|
||||
Vector2 minAnchor;
|
||||
Vector2 maxAnchor;
|
||||
|
||||
|
||||
private void Start()
|
||||
{
|
||||
var Myrect = this.GetComponent<RectTransform>();
|
||||
|
||||
minAnchor = Screen.safeArea.min;
|
||||
maxAnchor = Screen.safeArea.max;
|
||||
|
||||
minAnchor.x /= Screen.width;
|
||||
minAnchor.y /= Screen.height;
|
||||
|
||||
maxAnchor.x /= Screen.width;
|
||||
maxAnchor.y /= Screen.height;
|
||||
|
||||
|
||||
Myrect.anchorMin = minAnchor;
|
||||
Myrect.anchorMax = maxAnchor;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Gameton-06/Assets/Gameton/Scripts/Common/RectHelper.cs.meta
Normal file
11
Gameton-06/Assets/Gameton/Scripts/Common/RectHelper.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 196728227d77b9440af7a0e6102e7a6e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user