public static Rect AlignRect(float width, float height, Rect parentRect, GUIHelpers.Alignment alignment, float xOffset, float yOffset) { Rect rect; switch (alignment) { case GUIHelpers.Alignment.TOPLEFT: rect = new Rect(0f, 0f, width, height); break; case GUIHelpers.Alignment.TOPCENTER: rect = new Rect(parentRect.width * 0.5f - width * 0.5f, 0f, width, height); break; case GUIHelpers.Alignment.TOPRIGHT: rect = new Rect(parentRect.width - width, 0f, width, height); break; case GUIHelpers.Alignment.RIGHT: rect = new Rect(parentRect.width - width, parentRect.height * 0.5f - height * 0.5f, width, height); break; case GUIHelpers.Alignment.BOTTOMRIGHT: rect = new Rect(parentRect.width - width, parentRect.height - height, width, height); break; case GUIHelpers.Alignment.BOTTOMCENTER: rect = new Rect(parentRect.width * 0.5f - width * 0.5f, parentRect.height - height, width, height); break; case GUIHelpers.Alignment.BOTTOMLEFT: rect = new Rect(0f, parentRect.y + parentRect.height - height, width, height); break; case GUIHelpers.Alignment.LEFT: rect = new Rect(0f, parentRect.height * 0.5f - height * 0.5f, width, height); break; case GUIHelpers.Alignment.CENTER: rect = new Rect(parentRect.width * 0.5f - width * 0.5f, parentRect.height * 0.5f - height * 0.5f, width, height); break; default: rect = new Rect(0f, 0f, width, height); break; } rect.x += parentRect.x + xOffset; rect.y += parentRect.y + yOffset; return(rect); }
public static Rect AlignRect(float width, float height, GUIHelpers.Alignment alignment) { return(GUIHelpers.AlignRect(width, height, new Rect(0f, 0f, (float)Screen.width, (float)Screen.height), alignment, 0f, 0f)); }
public static Rect AlignRect(float width, float height, Rect parentRect, GUIHelpers.Alignment alignment) { return(GUIHelpers.AlignRect(width, height, parentRect, alignment, 0f, 0f)); }