I’m running a script that generates gizmo drawings in the cellular automata pattern of procedural generation. When I press play it generates a lot, too many, gizmos for my weak computer to properly render while I’m able to look at what is/was made. I want to freeze the frame so nothing continues to be generated while I can continue looking at the things in the gameview. I know there’s a pause button up top but it doesn’t stop scripts from running.
Feel free to ignore the comments, they were for my continued understanding more than anyone else.
As long as you use Time.time and Time.deltaTime for any form of movement, you can set Time.timeScale to 0 to “pause” the game or scene:
Time.timeScale = 0;
The Pause button “does” stop scripts, but only at “interruptible points”. If you have a script with an endless loop that can’t be interrupted until the method is finished. The scripting environment runs in a single thread, so if you stall the thread by an endless or very long loop that can’t be interrupted.
Well, it can be interrupted when using an attached code debugger, however only to debug the code. The editor will freeze just like your game. That means nothing is drawn and the editor can’t be used until your code finishes.
Unity is frame based. You can only interrupt between two frames. If you want to Pause the game in between frames from code you can use Debug.Break();. When Debug.Break is called Unity will pause at the next possible point, just like the editor does when you press the Pause button.
Again, a loop or currently running code can’t be interrupted. Your description almost sounds like you have such a situation, but you gave no further information.
edit
I just noticed your external linked code. You have to remove the Debug.Log from the loop. Debug.Log has a horrible execution time if it’s called that often. It will lower your performance by a factor of 10 to a 1000 times.
btw: What’s the values for “width” and “height”?