- Home /
Efficient GUI resizing
I'm using C# and I need my GUI to resize according to the screen. I've looked through some tutorials and stuff, and a lot of people just resize according to Screen measurements in the Update function. Is it more efficient to just store these variables and store them in a struct or something and then only change the values in the struct whenever the player changes the resolution in the menu? Or is there a better way?
Think of it this way:
With a large amount of GUI, would you rather have hundreds of variables (or lists) all with indistinguishable names, or would you rather have a ms or so more CPU time?
Well it wouldn't be hundreds of variables, it would only be a couple, like the ratio and maybe height and stuff right?
If you're only saving width/height and ratios, you'd still be doing a bunch of calculations per frame. If you wanted to get rid of this (tiny) overhead, you should calculate the Rect
for each GUI element and cache that.
I'm basically saying that doing what you are suggesting is either over optimizing or not optimizing at all :)
Just be smart in the way you run your GUI. Two GUI calls with cached Rect
's are way more expensive than one GUI call with normal calculations.
Okay, I suppose I'll only worry about it when it becomes a problem then, thanks
Your answer
Follow this Question
Related Questions
c# - void method from external class. 2 Answers
Android Resolution Problem 1 Answer
get the mouse cursor position x and y and make gui follow on trigger -1 Answers
GUI always changes Position with different resolutions. 2 Answers
OnGui Function help 1 Answer