- Home /
Most efficient way of pausing a function
Hi all. In terms of performance, what would be the most efficient way of achieveing this scenerio.
I have a Node script which is attached to many different objects in each scene. When a boolean is set to true, I need to call a function within another script.
My solutions:
I could create a public class variable in the Node script, however, this means I would need to assign the destination script to every single node which I feel isn't efficient...
I could use a while loop in my function. For example while(myBool == false) { return null; } //continue code
Or the other idea I had is using Update() and simply executing the code when myBool = true.
Anyone know which would be the best in terms of performance. I think the while loop but not 100% sure so that's what I will use for now. If anyone has any other solutions please let me know. Thanks folk!