/// <summary> /// Scale the source retangle in the GUIMember with a certain scale based on the default resolution set in the ResolutionManager.cs. /// </summary> public static Rect ResolutionRect(Rect rectangle, ResolutionManager.scaleMode mode) { Rect returnRect = new Rect(0, 0, 0, 0); scaleX = Screen.width / ResolutionManager.GetDefaultResolution().x; scaleY = Screen.height / ResolutionManager.GetDefaultResolution().y; //Different scaling modes for each GUIMember. (Default is ScaleWithResolution) switch (mode) { case ResolutionManager.scaleMode.keepPixelSize: returnRect = new Rect(rectangle.x * scaleX, rectangle.y * scaleY, rectangle.width, rectangle.height); break; case ResolutionManager.scaleMode.scaleWidth: returnRect = new Rect(rectangle.x * scaleX, rectangle.y * scaleY, rectangle.width * scaleX, rectangle.height); break; case ResolutionManager.scaleMode.scaleHeight: returnRect = new Rect(rectangle.x * scaleX, rectangle.y * scaleY, rectangle.width, rectangle.height * scaleY); break; case ResolutionManager.scaleMode.scaleWithResolution: returnRect = new Rect(rectangle.x * scaleX, rectangle.y * scaleY, rectangle.width * scaleX, rectangle.height * scaleY); break; } //The return value of the scaled rectangle of the source rect. returnRect = new Rect(Mathf.Round(returnRect.x), Mathf.Round(returnRect.y), Mathf.Round(returnRect.width), Mathf.Round(returnRect.height)); return(returnRect); }