[.NET] UI.DrawTexture position parameter & screen resolution
This question is for ScriptHookVDotNet.
For the life of me I couldn't find a single source that says what scale UI.DrawTexture uses for its 'position' parameter.
For my screen (at 1920x1080), the bottom-right is (1280, 720). Does this mean that the method always assumes the screen is 1280 x 720 for its positioning, regardless of actual resolution? If so, what happens with screens with non-widescreen aspect ratios?
@Razorwings18 For both position and size parameters, the X and Y are divided by UI.WIDTH and UI,HEIGHT, respectively. UI.WIDTH will always return 1280, and UI.HEIGHT will always return 720. If you want to get the real dimensions of the game window, you can use Game.ScreenResolution.Width (and Height).
To work around this you can do something like:
float adjustedWidth = (widthPixelsYouWant / (float)Game.ScreenResolution.Width) * UI.WIDTH; float adjustedHeight = (heightPixelsYouWant / (float)Game.ScreenResolution.Height) * UI.HEIGHT; Point pos = new Point((int)adjustedWidth, (int)adjustedHeight);
posas the position parameter. Similar thing for the size.
Thank you for confirming this. I'm working on a mod that needs to display an image at the center of the screen and just wanted to make sure that it'll work for others regardless of their resolution.