- Home /
Does GUIStyle.CalcSize harm the performance?
I have been doing an inventory system lately I have been using the GUILayout
functions for soo long time but after knowing that it does harm the performance if it is used extensively so, I switch to the good old normal GUI
functions.
Now I have come across a function known as GUIStyle.CalcSize();
so, I began using it and was wondering does it harm the performance if used let's say 25 times per frame?
Thanks in advance!
Answer by CosminS · Jan 06, 2018 at 07:22 PM
Anything that is done without actually needing is something you would like to avoid, because even if it's not eating a lot from your frame computation times, they tend to pile up. So later you will have optimization problems, and most probably low performance on low devices. I propose you to do something like this:
// any change of the text or the image in the content variable should flag this as true
if (contentChanged)
{
Vector2 size = GUIStyle.CalcSize(content)
// do something with the received size
}
I hope this helps (i know i'm a bit late with this info)
Your answer
Follow this Question
Related Questions
Make GUILayout horizontal first, then vertical? (C#) 3 Answers
Why Does IsPointerOverGameObject Not Work with GUILayout Controls? 0 Answers
Make children of a Layout Group fit their respective sizes (confusing docs) 1 Answer
How to position a GUI-Element relative to a game object? 0 Answers
Similar function in UI for GUILayoutUtility.GetRect 0 Answers