TheInitialProject/Assets/Scripts/UI/Base/Common.cs
2024-10-23 16:59:02 +08:00

45 lines
1.3 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Common
{
static public Vector2Int GetCurrScreenSize()
{
Vector2Int v2 = Vector2Int.zero;
// if (HotfixEntry.IsPC && UICrossPlatform.IsNewPlan)
// {
//#if UNITY_EDITOR
// v2.x = Screen.width;
// v2.y = Screen.height;
// return v2;
//#endif
// GetPC_ScreenSetting(out Vector2 size, out bool bFull);
// v2.x = (int)size.x;
// v2.y = (int)size.y;
// }
// else
// {
v2.x = Screen.width;
v2.y = Screen.height;
// }
return v2;
}
static public void SetRectTransformSize(RectTransform rectTrans, Vector2 newSize)
{
Vector2 oldSize = rectTrans.rect.size;
Vector2 offset = newSize - oldSize;
rectTrans.sizeDelta = rectTrans.sizeDelta + offset;
}
public static Vector2 ScreenXY_Stand = new Vector2(2778f, 1284f);
static public float GetUICrossPlatform_Mobile_ScalePr()
{
Vector2 v2 = GetCurrScreenSize();
return (v2.x / v2.y) / (ScreenXY_Stand.x / ScreenXY_Stand.y);
}
}