-
A delegate is something that acts on another thing's behalf.
-
So if Thing A needed something, Thing B to Thing Z could deliver that to Thing A. This makes Things B to Z all delegates to Thing A. Thing A invokes a delegate function. Thing A doesn't care who runs the errand. Thing A doesn't care how it happens. As long as it happens.
Delegate Invoker
- A class that contains a Delegate Reference to a Delegate Function and can invoke it any time.
Delegate Reference
https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/delegates/
- A type in C# that points to any function's address.
Delegate Function
- A function that can be invoked at any time. It's best for this function to be static, but
it doesn't have to be.
Delegate Class - Contains one or many Delegate Functions. May be any type of class.
- Can be a Controller, Service or a Behaviour.
- Doesn't have to be attached to a GO.
- Define delegates in terms of functionality.
- Naming format should be `"<Action>Delegate"`
This pattern allows you to assign different behaviors to a class. These behaviors are represented by delegates.
In this example, GameController will call a delegate to render some UI. But each scene needs to render UI a little bit differently. So I have defined a controller for each scene. The delegate's behavior is defined in this UI Controller.