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?
Attaching scripts to instances
1760 2 0- maxpleaner
- Member
- 16 posts
- Joined: July 2020
- Offline
- anthonyt2
- Member
- 100 posts
- Joined: Dec. 2020
- Offline
- maxpleaner
- Member
- 16 posts
- Joined: July 2020
- Offline
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.
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.
-
- Quick Links