Documentation

Learn how to use NodeCanvas

Download PDF Version

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 definition. With that in mind, 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 constrain.
  • Only one generic parameter is allowed.

GericTaskSelection

GenericTask

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

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