Another good use of delegates is a messaging system between classes. A list of delegates can be created as a way to keep track of the receivers, that way we always know where the message will be going. The 'listeners' can then chose whether or not they act on the message depending on what it is.
![]() |
Example of using delegates for message system |
A co-routine is a method that can be paused and continued later. This is very useful to script events and create situations where something is waited for or triggered at a certain time. Using a co-routine that contains yield is what causes it to continue in the next frame from where it left off in the last one, rather than starting from scratch. This is what I've done in order to fade out the bullet holes in previous projects I've done so it's good to find out I did it to a proper standard. A co-routine can also be stopped at any time but only by calling it's name, giving you even greater control on how it carries out.
![]() |
Co-routine that fades and resets colour |
No comments:
Post a Comment