Houdini Engine for Unity
 All Files Pages
Unity Scripts

Existing Unity Component-derived scripts can be attached to the asset's output GameObjects via custom attributes. Additionally, a function on the script can be invoked with an optional string argument. This is done after the asset has been fully cooked and all of its outputs generated. Note that the specified Component will only be added if the GameObject does not already have it. The function will be invoked on every recook though.

The attribute must be a detail attribute of string type, with name unity_script. It must have the following format:


The script_component_name should be the name of the Component-derived class in Unity.

The function_name should be the name of a function within the Component, and is optional. If invoking a function, the class must also have the **[ExecuteInEditMode]** tag.

The argument could be any string-value and is optional. This allows to pack and send any values that can be parsed by the receiver.

For example, if you have a script called Test.cs such as the following:

public class Test : MonoBehaviour
public string _msg;
void HDACallbackWithMsg(string msg)
Debug.Log("Callback with msg: " + msg);
void HDACallbackNoMsg()
Debug.Log("Callback with no msg");

Then, the custom attribute could be one of the following, depending on the callback:

Only attach the script. No callback.


Attach script and do callback, no argument:


Attach script, do callback with argument:

Test:HDACallbackWithMsg:hey this is a message

Multiple scripts can be attached by adding a semi-colon between each script name:


To see a working example, load the HoudiniEngineUnity/Examples/HEU_Example_Unity_Script.hda in Unity. It will attach HoudiniEngineUnity/Scripts/Examples/HEU_ScriptCallbackExample.cs to the asset's output GameObject, and invoke the function with argument containing the message "Hello".