|
I have just stared down the wonderful road of InvokeRepeating methods. What I would like to know is; is there a easy way to toggle these methods on and off. For example lets say I have a class with
and I want the component to spawn new characters only when its not adding resources, and vice versa. I had thought about making one method that will spawn either or based on a toggle, but I know I will be extending this class and adding other possible actions.
(comments are locked)
|
|
You can use CancelInvoke where necessary, but it sounds like coroutines would be more appropriate for this than InvokeRepeating.
In this case, setting "addingResource" to true or false toggles between the two functions. Yeah I think your right, co routines would be more appropriate, thanks.
Apr 29 '11 at 12:57 AM
Siegeon
(comments are locked)
|
|
http://unity3d.com/support/documentation/ScriptReference/MonoBehaviour.CancelInvoke.html Seems like you could do that easy enough Thank you for your quick reply, the example that you posted(and I had already looked at) does not show how you would toggle the method back on once I were no-longer collecting resources.
Apr 29 '11 at 01:01 AM
Siegeon
(comments are locked)
|
