Should it be this slow?

Bin using unity for some time now but I never really messed with GUI’s so I thought I might as
well add it to my game. And when I did my profiler showed rather interesting drop in performance.
So I’m just wondering is a script like:

var gold = 0.0;
var wood = 0.0;
var iron = 0.0;
var stone = 0.0;

function OnGUI(){
	GUI.Label (Rect (10, 10, 100, 20), "Gold  " +gold);
	GUI.Label (Rect (10, 20, 100, 30), "Wood  " +wood);
	GUI.Label (Rect (10, 30, 100, 40), "Iron  " +iron);
	GUI.Label (Rect (10, 40, 100, 50), "Stone  " +stone);
}

supposed to take up 60% of my CPU and drop my frame rate from 60fps to 5.4fps?

Anyway I must be doing something wrong. Just would like to what it is and why it’s so important.

It’s been mentioned that using GUI functions can incur a noticeable performance hit, but if you’re actually getting fewer than 6 frames per second, I’d think that would mean there’s something pathologically wrong with your project or system setup.

I didn’t spot anything obviously wrong with the code you posted (although maybe somebody else will). What happens if you only display one label, or two, or three? Does the frame rate change proportionally? If you comment out the OnGUI() function, does the frame rate go back to normal?

Well it seems that removing 1, 2, 3 and even all 4 labels have no effect.
But commenting out all of OnGUI does bring the frame rate back to normal.

do you have 100 GOs with this script?

No just one. But I do have maybe 7 GO’s accessing it’s var’s at most and that’s almost never.

that wouldn’t touch it.
for it to go that ugly, there must be something that drags work to the ongui calls on its own (like another ongui with 2 dozen gadgets that generate events) …

or you are testing it on a netbook :wink:

Well yes I am using a notebook. As for other OnGUI’s I do have then in my scene but the have bin turned off for my testing.

notebook != netbook
although if you have an intel, they are the same cause then thats very well a good reason for the problems if you have a business or “light surfing” notebook

I am using a dell latitude D610 with intel processor. It’s not the fastest thing in the world but it is still a pretty good laptop (or notebook if you will).

But perhaps it really is this computer I will have to give it a go on our desktop.