public static string SetOffset(string key, float newValue) { SafeScreenUtils.safeRect = SafeScreenUtils.invalidRect; key = key.ToLower(); if (key != null) { if (!(key == "x")) { if (!(key == "y")) { if (!(key == "w")) { if (key == "h") { SafeScreenUtils.forceHeightOffset = newValue - (float)Screen.height; } } else { SafeScreenUtils.forceWidthOffset = newValue - (float)Screen.width; } } else { SafeScreenUtils.forceYOffset = newValue; } } else { SafeScreenUtils.forceXOffset = newValue; } } return(SafeScreenUtils.GetSafeRectString()); }
public static void PrepAssetForScreenSize(object asset) { GameObject gameObject = asset as GameObject; if (gameObject == null) { return; } GameObject gameObject2 = UnityUtils.FindGameObject(gameObject, "WidgetSafeArea"); if (gameObject2 == null) { return; } UIWidget component = gameObject2.GetComponent <UIWidget>(); Rect safeArea = SafeScreenUtils.GetSafeArea(); if (safeArea.width < (float)Screen.width || safeArea.height < (float)Screen.height || safeArea.x > 0f || safeArea.y > 0f) { if (SafeScreenUtils.useFixedAnchors) { component.leftAnchor.absolute = 53; component.topAnchor.absolute = 0; component.rightAnchor.absolute = -53; component.bottomAnchor.absolute = 0; } else { component.leftAnchor.absolute = (int)safeArea.x; component.topAnchor.absolute = (int)safeArea.y; component.rightAnchor.absolute = (int)(safeArea.width - (float)Screen.width); component.bottomAnchor.absolute = (int)(safeArea.height - (float)Screen.height); } } }
public static string ResetRect() { SafeScreenUtils.safeRect = SafeScreenUtils.invalidRect; SafeScreenUtils.forceXOffset = 0f; SafeScreenUtils.forceYOffset = 0f; SafeScreenUtils.forceWidthOffset = 0f; SafeScreenUtils.forceHeightOffset = 0f; return(SafeScreenUtils.GetSafeRectString()); }
public static string GetSafeRectString() { Rect safeArea = SafeScreenUtils.GetSafeArea(); return(string.Format("x:{0} y:{1} w:{2} h:{3}", new object[] { safeArea.x.ToString("F1"), safeArea.y.ToString("F1"), safeArea.width.ToString("F1"), safeArea.height.ToString("F1") })); }