Skip to main content

Nodos

Los nodos son unidades de lógica que pueden conectarse entre sí para crear comportamientos complejos. Se pueden pensar como funciones en un programa pero con una representación visual.

Definición de Tipo

Puedes crear tipos de nodo que pueden ser instanciados y almacenados en un blueprint. Un tipo de nodo hereda del tipo Node y está decorado con el atributo [NodeType], como se muestra abajo:

using Warudo.Core.Attributes;
using Warudo.Core.Graphs;

[NodeType(
Id = "c76b2fef-a7e7-4299-b942-e0b6dec52660",
Title = "Hello World",
Category = "CATEGORY_DEBUG",
Width = 1f
)]
public class HelloWorldNode : Node {
// Node implementation
}

Aquí hay un resumen de los parámetros:

ParámetrosTipoTipo de DatoDescripción
IdObligatoriostringEl identificador único de esta clase de nodo.
Debes generar un nuevo GUID para cada nuevo tipo de nodo.
Nota: el Id de la clase de nodo es diferente del UUID de una instancia de nodo (node.Id).
TitleOpcionalstringEl nombre de este nodo que se mostrará en la paleta de nodos.
CategoryOpcionalstringEl grupo de este nodo en la paleta de nodos.
WidthOpcionalfloatEl ancho de este nodo, que por defecto es 1f.
Un nodo con un ancho de 2f ocupará el doble de espacio que un nodo con un ancho de 1f.
About Category
  • You can use the built-in Category strings listed in the Table below.
    • They will be automatically localized to the program's language.
  • You can also use your own custom Category names.
    • We strongly recommend doing this when you want to upload this node to the workshop.
    • And using the plugin name as the Category allows users to more clearly know that the node they are using is from a plugin, and which plugin is the node from.

Table The built-in Category strings and their localized text.

Categoryenzh_CNja
CATEGORY_ACCESSORIESAccessories配件付属品
CATEGORY_ANIMATIONAnimation动画アニメーション
CATEGORY_ARITHMETICArithmetic运算計算
CATEGORY_ASSETSAsset资源アセット
CATEGORY_BLENDSHAPESBlendShapesBlendShapeBlendShape
CATEGORY_CHARACTERSCharacters角色キャラクター
CATEGORY_CINEMATOGRAPHYCinematography摄影撮影
CATEGORY_CONDITIONALSConditionals条件条件
CATEGORY_CONTROL_FLOWFlow Control流控制フローコントロール
CATEGORY_DATAData数据データ
CATEGORY_DEBUGDebug调试デバッグ
CATEGORY_ENVIRONMENTSEnvironment环境環境
CATEGORY_EVENTSEvents事件イベント
CATEGORY_EXTERNAL_INTEGRATIONExternal Integration外部集成外部統合
CATEGORY_GRAPHSBlueprints蓝图ブループリント
CATEGORY_INPUTInput输入
CATEGORY_LIGHTSLights光源ライト
CATEGORY_LITERALSLiterals字面量リテラル
CATEGORY_MOTION_CAPTUREMotion Capture动作捕捉モーションキャプチャー
CATEGORY_PROPProps道具道具
CATEGORY_SCENEScene场景Scene
CATEGORY_SWITCHESSwitches切换切り替え
CATEGORY_VARIABLESVariables变量変量

Componentes

A node type can define data inputs, data outputs, flow inputs, flow outputs, and triggers.

Ciclo de Vida

In addition to the lifecycle stages listed on the Entities page, nodes have the following additional lifecycle stages:

  • OnAllNodesDeserialized(): Called after all nodes in the belonging blueprint are deserialized. This is useful when you need to access other nodes in the same blueprint.
  • OnUserAddToScene(): Called when the node is just instantiated in the blueprint editor, by the user dragging it from the node palette.

Activando Flujos

You can trigger an output flow by returning the Continuation of the flow output in a flow input method. For example:

[FlowInput]
public Continuation Enter() {
// Do something
return Exit;
}

[FlowOutput]
public Continuation Exit;

If your flow ends here, you can return null to indicate that the flow has ended.

[FlowInput]
public Continuation Enter() {
// Do something
return null;
}

Sometimes, you may want to delay the flow output or trigger a flow output manually. You can use the InvokeFlow(string flowOutputPortKey) method to trigger a flow output. For example:

[FlowInput]
public Continuation Enter() {
async void TriggerExitLater() {
await UniTask.Delay(TimeSpan.FromSeconds(5));
InvokeFlow(nameof(Exit)); // Start a new flow from the "Exit" output port
}
return null; // You still need to return a Continuation. Since *this* flow technically ends here, we return null
}

Data Inputs y Outputs No Serializables

One thing special about nodes is that they can have non-serializable data inputs and outputs (you can't do that in assets or plugins - they will just not display at all). This allows nodes to pass, e.g., Unity objects like GameObject or Texture2D between each other and process them.

You can even have a generic data input or output, like this:

[DataInput]
public object MyGenericInput; // Note it's 'object', not 'Object'

[DataOutput
public object MyGenericOutput() => ...

Data output port of any type can be connected to MyGenericInput (the value will just be upcast to object). Conversely, MyGenericOutput can be connected to any data input port, but the value received by the input port will be null if the input port type is not compatible with the underlying type of what MyGenericOutput returns.

Convertidores de Tipos

When connecting nodes, you will notice Warudo will automatically convert the data type if possible. For example, it is possible to connect a float output to an int input - the value is simply truncated.

You can register custom type converters using the DataConverters class. The easiest way is to implement the DataConverter<T1, T2> class:

public class MyFloatToIntConverter : DataConverter<float, int> {
public override int Convert(float data) => (int) data;
}

Then, register the converter in the OnCreate method of your plugin:

public override void OnCreate() {
base.OnCreate();
DataConverters.RegisterConverter(new MyFloatToIntConverter());
}
caution

You should not register type converters in your node type's OnCreate - you will register them each time a node instance is created!

Ejemplos de Código

Básico

Avanzado

Contributions

Edit on Github

Translators

Last updated on 2026.01.18