Learn how to use NodeCanvas

Creating Generic Tasks

NodeCanvas uses a lot of generics and you also have the ability to create and use generic action and condition Tasks, which make things much more reusable without the need to write countless of tasks doing the same thing.

This works well with the fact that BBParameter is also a generic type. With that in mind, the following is the code of the included SetVariable<T> action task.

Then, in the editor when you are to select an ActionTask, the generic task will be shown as a category where you will be able to select the type of T. Some things to keep in mind:

  • The types shown in the editor will be those that are set in the Prefered Types Editor Window.
  • The types shown will be constrained in case T has a constraint.
  • Only one generic argument is allowed and supported.


Finally here is another example code from the included AddElementToList<T> action task.

Yes No Suggest edit
10 of 10 users found this section helpful
Suggest Edit