public static void SetAnchor(RectTransform rt, UIANCHORPOS pos) { float x = 0; float y = 0; _get_anchorpos(pos, ref x, ref y); rt.anchorMax = new Vector2(x, y); rt.anchorMin = new Vector2(x, y); }
private static void _get_anchorpos(UIANCHORPOS pos, ref float x, ref float y) { if (pos == UIANCHORPOS.TL) { x = 0; y = 1; } if (pos == UIANCHORPOS.TC) { x = 0.5f; y = 1; } if (pos == UIANCHORPOS.TR) { x = 1; y = 1; } if (pos == UIANCHORPOS.ML) { x = 0; y = 0.5f; } if (pos == UIANCHORPOS.MC) { x = 0.5f; y = 0.5f; } if (pos == UIANCHORPOS.MR) { x = 1; y = 0.5f; } if (pos == UIANCHORPOS.BL) { x = 0; y = 0f; } if (pos == UIANCHORPOS.BC) { x = 0.5f; y = 0f; } if (pos == UIANCHORPOS.BR) { x = 1; y = 0f; } }
public static void SetAnchor(GameObject go, UIANCHORPOS pos) { var rt = go.GetComponent <RectTransform>(); SetAnchor(rt, pos); }
public static void SetPivot(RectTransform rt, UIANCHORPOS pos) { }