Houdini Engine for Unity
 All Files Pages
Visual Scripting

Basic Unity Visual scripting support is available in Unity 2021.1+. Currently, there are two Unit nodes: Instantiating HDAs and Modifying HDAs . These nodes are editor-only, and activated using a manually clicked button since Houdini Engine is not officially supported during runtime.

Visual scripting support is only available in Unity 2021.1, but will still be included in the the .unitypackage file. It should not create compiler errors for previous version of Unity, nor should it block the build for any previous versions of Unity.

This feature is in beta, meaning if you have any suggestions for improvements, please let us know by submitting an RFE here

Setup

In order to see the Visual scripting nodes into the Unity Visual Scripting Graph, you must first load the HoudiniEngineUnity and HoudiniEngineUnity.VisualScripting assembly references.

The Visual Scripting Project Settings page can be found in Edit > Project Settings > Visual Scripting. From there, you must expand the "Node Library" dropdown, add the HoudiniEngineUnity and HoudiniEngineUnity.VisualScripting assembly definitions, and then click "Generate Units." Additionally, we use custom inspector properties, so you must also click Custom Inspector Properties > Geenrate as well.

Unity_VisualScripting_AssemblyReferences.png

After loading the necessary assemblies, the Instantiating HDAs and VisualScripting_Modifying_HDA nodes should be available to use in the Visual Scripting Graph.


Instantiating HDAs

The Unit responsible for instantiating new HDA assets can be found in Events/Editor/Houdini Engine/Houdini Engine Instantiate HDA. It contains input parameters to specify the HDA path (relative to the Assets folder), whether or not to load it asynchronously, and the instantiation position. If you imported the plugin using the .unitypackage without modifying the asset hierarchy, then the default HDA path parameter "Assets/Plugins/HoudiniEngineUnity/HDAs/EverGreen.otl" should instantiate the EverGreen example HDA asset. (i.e. it should work without changing any of the parameters) After setting up your parameters, you can click the "Instantiate HDA" button to start the instantiation process.

The control flow will then yield until the HDA asset has been built. If the "async" parameter is false, then it will block user input until then. When the HDA asset has finished cooking, the flow of execution will resume. The node has three main output parameters: Success, indicating whether or not the cook was successful, "Output HDA Root", which is the reference to the HEU_HoudiniAssetRoot, and "Output HDA", which is just a helper to the HEU_HoudiniAsset, where is usually where you perform operations.

This is an example of a Visual Scripting Graph that instantiates an EverGreen HDA, and then sets the leaves to red.

Unity_VisualScripting_HDAInstantiating.png

Note: If your HDA has a required input, you may want to disregard the Success output, as it will always be false due to invalid number of inputs.


Modifying HDAs

It is often the case that you want to modify existing HDAs. The current workflow is to have your HDAs (With the component HEU_HoudiniAssetRoot) as a graph Scene Variable.

Unity_VisualScripting_Scene_Variables.png

Then, using the Scene Variable reference, attach it to a Events/Editor/Houdini Engine/Houdini Engine Modify HDA node. This node is simply a wrapper to the ManualUnit class that allows you to trigger the flow of execution from within the Unity editor. You can use the Output HDA parameter of type HEU_HoudiniAsset to then modify the asset as you wish.

For example, here is an example of a graph that takes a EverGreen HDA, and then modifies the leaves to a random color.

Unity_VisualScripting_HDAModify.png