Skip to content

Delegates

JasonJonesLASM edited this page Jun 28, 2021 · 29 revisions

Delegates are a way to create and invoke methods by reference. As the name suggests, a Delegates main intention is to delegate the behavior amongst one or many other methods. This allows one variable to bind and unbind other matching methods, then invoke them based on that single reference. These can be created and bound at runtime, to switch and assign new behaviour to variables and third party scripts. This is perfect for modularity and abstraction!

You may have seen some inaccessible ports before. Perhaps, labeled as "callback", "getter", "setter", "On Click", and so forth. The only way to utilize them, was to create a C# script or wrapper for them. We have done this for you, by creating assets that can generate native C# wrappers that the delegate units use.

There are two types of delegates:

Actions - A delegate with no return values. These must be a type of void.

Funcs - A delegate with a return value.

Clone this wiki locally