screen adjust

This commit is contained in:
2020-07-11 10:57:19 +08:00
parent 19eaa467e9
commit f563839566
20 changed files with 713 additions and 549 deletions

View File

@@ -1727,19 +1727,22 @@ static public class NGUITools
mGameSize = (Vector2)s_GetSizeOfMainGameView.Invoke (null, null);
}
return mGameSize;
}
}
#else
#else
/// <summary>
/// Size of the game view cannot be retrieved from Screen.width and Screen.height when the game view is hidden.
/// </summary>
static public Vector2 screenSize { get { return new Vector2(Screen.width, Screen.height); } }
//static public Vector2 screenSize { get { return new Vector2(Screen.safeArea.width, Screen.safeArea.height); } }
#endif
#region add by chenbin
#region add by chenbin
public static void updateAll (Transform tr)
public static void updateAll (Transform tr)
{
UILabel label = tr.GetComponent<UILabel> ();
if (label != null) {
@@ -1813,22 +1816,49 @@ static public class NGUITools
}
}
public static Rect wrapRect4IphoneX(Rect rect) {
return wrapRect4Fringe (rect);
}
public static Vector4 _offsetRect;
public static Vector4 offsetRect
{
get
{
if (_offsetRect == null)
{
float left = Screen.safeArea.x;
float right = Screen.width - Screen.safeArea.width - left;
float top = Screen.safeArea.y;
float bottom = Screen.height - Screen.safeArea.height - top;
public static Rect wrapRect4Fringe(Rect rect) {
if (isFringe) {
if (rect.width > rect.height) {
float offsetWidth = rect.width * (1 - rateFringe);
return new Rect ((int)(offsetWidth / 2), 0, rect.width - offsetWidth, rect.height);
} else {
float offsetHight = rect.height * (1 - rateFringe);
return new Rect (0, (int)(offsetHight / 2), rect.width, rect.height - offsetHight);
_offsetRect = new Vector4(left/Screen.width, top / Screen.height, right / Screen.width, bottom / Screen.height);
}
} else {
return rect;
return _offsetRect;
}
set{
_offsetRect = value;
}
}
public static Rect wrapRect4Fringe(GameObject go, Rect rect) {
//if (isFringe) {
// if (rect.width > rect.height) {
// float offsetWidth = rect.width * (1 - rateFringe);
// return new Rect ((int)(offsetWidth / 2), 0, rect.width - offsetWidth, rect.height);
// } else {
// float offsetHight = rect.height * (1 - rateFringe);
// return new Rect (0, (int)(offsetHight / 2), rect.width, rect.height - offsetHight);
// }
//} else {
// return rect;
//}
Vector4 offset = offsetRect;
float left = rect.width * offset.x;
float right = rect.width * offset.z;
float top = rect.height * offset.y;
float bottom = rect.height * offset.w;
rect.x += left;
rect.width -= (left + right);
rect.y += bottom;
rect.height -= (top + bottom);
return rect;
}
#endregion
}