This commit is contained in:
2020-07-11 12:36:54 +08:00
parent f563839566
commit e84465cd64
26 changed files with 247 additions and 248 deletions

View File

@@ -1768,6 +1768,7 @@ static public class NGUITools
}
}
/*
public static bool isIphonex() {
#if UNITY_IOS
#if UNITY_2017_1_OR_NEWER
@@ -1791,42 +1792,46 @@ static public class NGUITools
#endif
return false;
}
*/
//static bool _isFringe = false;
//public static bool isFringe { // 刘海屏
// get {
// return _isFringe || isIphonex ();
// }
// set {
// _isFringe = value;
// }
//}
static bool _isFringe = false;
public static bool isFringe { // 刘海屏
get {
return _isFringe || isIphonex ();
}
set {
_isFringe = value;
}
}
static float _rateFringe = 1;
public static float rateFringe {
get {
if (isFringe) {
return 734f / 812f;
} else {
return _rateFringe;
}
}
set {
_rateFringe = value;
}
}
//static float _rateFringe = 1;
//public static float rateFringe {
// get {
// if (isFringe) {
// return 734f / 812f;
// } else {
// return _rateFringe;
// }
// }
// set {
// _rateFringe = value;
// }
//}
public static Vector4 _offsetRect;
static bool initOffsetRect = false;
public static Vector4 offsetRect
{
get
{
if (_offsetRect == null)
{
if (!initOffsetRect)
{
initOffsetRect = true;
Debug.LogWarning("Screen.safeArea)========"+Screen.safeArea);
Debug.LogWarning(Screen.width+","+ Screen.height);
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;
float bottom = Screen.safeArea.y;
float top = Screen.height - Screen.safeArea.height - bottom;
_offsetRect = new Vector4(left/Screen.width, top / Screen.height, right / Screen.width, bottom / Screen.height);
}

View File

@@ -1126,6 +1126,7 @@ public class UIWidget : UIRect
float leftOffset = offsetRect.x;
float rightOffset = offsetRect.z;
float topOffset = offsetRect.y;
float bottomOffset = offsetRect.w;
UIPanel panel = null;
#endregion
@@ -1142,6 +1143,7 @@ public class UIWidget : UIRect
leftOffset *= panel.width;
rightOffset *= panel.width;
topOffset *= panel.height;
bottomOffset *= panel.height;
} else
{
leftOffset = 0;
@@ -1154,7 +1156,13 @@ public class UIWidget : UIRect
{
lt = NGUIMath.Lerp(sides[0].x, sides[2].x, leftAnchor.relative) + leftAnchor.absolute + leftOffset;
rt = NGUIMath.Lerp(sides[0].x, sides[2].x, rightAnchor.relative) + rightAnchor.absolute - rightOffset;
bt = NGUIMath.Lerp(sides[3].y, sides[1].y, bottomAnchor.relative) + bottomAnchor.absolute - topOffset;
if(bottomAnchor.absolute < 0)
{
bt = NGUIMath.Lerp(sides[3].y, sides[1].y, bottomAnchor.relative) + bottomAnchor.absolute - topOffset;
} else
{
bt = NGUIMath.Lerp(sides[3].y, sides[1].y, bottomAnchor.relative) + bottomAnchor.absolute + bottomOffset;
}
tt = NGUIMath.Lerp(sides[3].y, sides[1].y, topAnchor.relative) + topAnchor.absolute - topOffset;
mIsInFront = true;
}
@@ -1164,7 +1172,7 @@ public class UIWidget : UIRect
Vector3 lp = GetLocalPos(leftAnchor, parent);
lt = lp.x + leftAnchor.absolute + leftOffset;
bt = lp.y + bottomAnchor.absolute - topOffset;
rt = lp.x + rightAnchor.absolute - rightOffset;
rt = lp.x + rightAnchor.absolute + rightOffset;
tt = lp.y + topAnchor.absolute - topOffset;
mIsInFront = (!hideIfOffScreen || lp.z >= 0f);
}
@@ -1243,6 +1251,7 @@ public class UIWidget : UIRect
leftOffset *= panel.width;
rightOffset *= panel.width;
topOffset *= panel.height;
bottomOffset *= panel.height;
}
else
{
@@ -1254,11 +1263,11 @@ public class UIWidget : UIRect
if (sides != null)
{
bt = NGUIMath.Lerp(sides[3].y, sides[1].y, bottomAnchor.relative) + bottomAnchor.absolute - topOffset;
bt = NGUIMath.Lerp(sides[3].y, sides[1].y, bottomAnchor.relative) + bottomAnchor.absolute + bottomOffset;
}
else
{
bt = GetLocalPos(bottomAnchor, parent).y + bottomAnchor.absolute - topOffset;
bt = GetLocalPos(bottomAnchor, parent).y + bottomAnchor.absolute + bottomOffset;
}
}
else bt = pos.y - pvt.y * mHeight;