Search - User list
Full Version: Attaching scripts to instances
Root » Houdini Engine for Unity » Attaching scripts to instances
maxpleaner
I have a "shrub" model which I am copying to points using the "pack & instance" option.

To cut to the chase, I need to attach a script to each grass instance (to apply some optimizations to the mesh renderer).

I thought the docs were pretty straightforward (https://www.sidefx.com/docs/unity/_unity_scripts.html). I set a `unity_script` detail attribute with value "MeshRendererConfig:HDA_Created" - MeIshRendererConfig is the script and HDA_Created is the callback. I know it's being attached fine because I get console messages from the callback.

However the problem is where the script is being attached. It is not something with a MeshRenderer, and is only attached once, not on every instance like I want. See the following screenshot:



I suppose I could loop through child objects from the script, but the place where it's attached isn't even a parent of the actual instances - it's this mysterious HDA_Data thing. Probably there's a workaround where I write some hacky Unity code to find the correct components by name. But it'd be so much nicer if I could just attach the script to each instance. Is this really not possible?
anthonyt2
Hi, if you could send an HDA, that will help me diagnose the issue that you are having.
maxpleaner
I ended up circumventing this by using `unity_instance` instead of the direct Houdini => Unity mesh creation.

I don't have a HDA but it should be really straightforward to reproduce, just make any Houdini geo with a `unity_script` attribute and copy to points using "Pack and Instance" before importing into Unity ..

I think I just misunderstood the capabilities of the system. Possibly it's not a bug per se but more of a feature request.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB