Skip to content

Delegate Assets

JasonJonesLASM edited this page Jun 28, 2021 · 4 revisions

Types

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.

Each delegate has a Delegate Unit, an Invoke Unit, and a Bind and Unbind Unit. These units are auto populated into the Community > Control > Delegates folder in the Fuzzy Finder, under the delegate types Namespace.

Create a Delegate

To ensure all delegates work the same on all platforms, it was decided, generating to C# was the best option. In order to utilize a delegate, you must first create a new delegate asset to compile a wrapper, for use in graphs. Selecting a type will be based on what units you are using, and their requirements. You will be able to find them by inspecting the unit port for its type.

In the Project Window, right click and select Visual Scripting > Community > Delegate to create a new Delegate Asset.

Delegates

Generic Parameters

If a type has generic parameters, you will be required to fill out each parameter below the type. You are not required to know the types allowed for the constraint. They are automatically filtered based on the constraint type.

Delegate With Constraint

Compile

If you are satisfied with what you've done, you may compile using the Compiler Utility. All Delegates C# scripts, are compiled into "Assets/Bolt.Addons.Generated/Scripts/Delegates" folder.

You only need to regenerate units when you first import the version with Delegates in it. All uses of the wrappers and the populated fuzzy finder, are dynamic.

Clone this wiki locally