performance

I am very new to this… but starting to think way too far into my project…

way too far!!

a lot of the tutorials I am looking at, make use of the update function or ongui, which if I understand it correctly are run every frame… which is great for etting some stuff to work, but isn’t it a huge performance overhead??

take ongui… I have an on screen console up, if the code is checking 25 plus times a second and redrawing that, isn’t that a bad use of resource…

I am sure its academic just now, as I only have one playe, but when I am linking it with a handful of other players data being pipped down to the game, its all going to add up isn’t it??

any thoughts?

N

It’s definitely a good idea to avoid using Update as much as possible. Also I avoid the GUI stuff completely. Look into NGUI or similar.

Become friends with Invoke and InvokeRepeating :smile:

Invoke("SomeFunction",2); // Runs SomeFunction a single time in 2 seconds. 

InvokeRepeating("SomeFunction",2,1); // Run SomeFunction repeatedly every seconds starting in 2 seconds.

Cancelnvoke("SomeFunction"); // Cancels the Invoke or InvokeRepeating.

The truth about GUI stuff is even worse than you imagine. It can (and often does) generate multiple calls in the same frame. Which is OK I guess as the built-in GUI stuff is more of a development tool than production code and you’ll likely see more performance out of a 3rd party package like ngui.

As far as Update is concerned, limit code in this section to stuff that MUST be updated each frame. Generally your co-routines will handle most of the periodic functions as meta87 pointed out. Both invoke and invoke repeating are useful but I personally tend to write the function as it would appear if called from an update but use yield statements (another example of co-routines) to control it’s execution.

Cheers Guys…

I may as well try and break the bad habits before I get them…

I will look at nGUI as both of you mentioned it…

and I guess I need to read about yield stuff and invoking!!

I guess my thinking on update and ongui is going to be nothing when it comes to many multi users all wondering around the same romm in game… but i’ll cross that bridge when I come to it!!

Cheers again…