Using a For loop in Update()...bad idea?

I think I know the answer, but I just want confirmation and some kind of evidence…

I have a script with a for loop being run in the Update() function. This script is on several prefabs, each of which can be instantiated several times. (We are students trying to make a simple real time strategy…) Am I right in assuming, the more clones are called, the more loops are running per frame, and the slower my frame rate will crash?

In other words… while update has it’s uses, can I assume over-use can dump my game into the unplayable bin? Is this also true for OnGUI?

You have to do your own Profiling on your target device to decide if there is actually a problem with performance and where that problem is.

That being said, there is nothing wrong with a for loop in Update(), even many times.

If it is not super essential that these for loops are calculated by the end of the frame you can simply run these processes in a coroutine to have the processing spread over many frames.

Update() is generally the most used Mono function. It constitutes the main game loop. Whereas you can make a game entirely without it if you choose, it is basically a pre-made ticker and takes out a lot of the backend work associated with making a game engine.

It is perfectly acceptable to run for loops inside an Update() function. Most for loops will take very little time to execute. You must simply make sure not to bloat the loop with unnecessary calculations else your delay time becomes somewhat exponential with every extra iteration of the loop, given the extra time needed in each loop-through.