Instancing Unity prefab with Houdini ?

   244   6   0
User Avatar
Member
2 posts
Joined: Sept. 2019
Offline
Hello, I'm an Unity developer but I'm new to Houdini.

My question is, as our old workflow, I have prefabs in Unity which have some scripts/lods/colliders configured on them. I want to input them to a .hda and populate them along a curve with Houdini, preserving those scripts/lods/colliders.

I checked the docs and tried for a while, but I find that the prefabs are inputted in Houdini as meshes and the scripts/lods/colliders are lost in the generated asset.

So how can I preserve the components attached on the prefabs in the generated assets, thanks?
User Avatar
Staff
452 posts
Joined: May 2017
Online
If you are simply instancing the source prefab, and not changing the mesh geometry in Houdini, then you don't need to use them as input meshes. Rather, in your HDA, add a string or path parm to just take the Unity asset path to the prefab, then on the curve points, add a unity_instance string attribute. Their value should be the asset path you provided in your parm. This simply instances the prefabs on export, and keeps everything intact. Note that in order to use unity_instance attribute to create instances, the output geo must only have points (no primitives).
https://www.sidefx.com/docs/unity/_instancing.html#ObjectInstancers_Attribute [www.sidefx.com]

If you need to bring in the mesh into Houdini for modification, you should split up your HDA to generate two objects:
1. Generates new mesh based on your source input mesh.
2. Generates instances using the prefab path like I described above.
3. In a post cook event, replace the prefab instance mesh with your new mesh from 1. https://www.sidefx.com/docs/unity/_assets.html#Assets_AssetInspectorUI_Events [www.sidefx.com]
Edited by seelan - Sept. 23, 2019 08:51:10
User Avatar
Member
2 posts
Joined: Sept. 2019
Offline
Saved the day! Thank you so much
User Avatar
Member
12 posts
Joined: May 2017
Offline
Piggy backing on the main question.
I hava a HDA that does exactly that: it takes path to Unity prefab stored in unity_instance attribute and among other things places this prefab along curve path.

Our workflow is that at the end all content created with the HDA is baked into objects (not prefabs). These objects are grouped together under parent Unity Game Object and all this is saved as a major prefab.
We do this to allow multiple team members to work on the same Unity scene at the same time.

I noticed some strange behavior:
Every time I recook or rebake HDA that uses some Unity prefab (let's call it prefab A) - it will cause Unity to update every major prefab where said prefab A is also used. The more scenes in the project the longer it takes to go through all the major prefabs. I am writing this post while waiting for Unity to finish recooking 20 HDAs due to some changes in the HDA definition. Every HDA causes series of “Hold on…” pop ups:


I'd appreciate some information on why it might be happening and how to get rid of it.
Cheers,
STC
Edited by staszek-c - Oct. 10, 2019 08:17:07

Attachments:
UpdateIssue.jpg (13.8 KB)

User Avatar
Staff
452 posts
Joined: May 2017
Online
Does the long prefab update also happen if you make a change directly to the prefab and apply it (i.e. not going through Houdini Engine)?
User Avatar
Member
12 posts
Joined: May 2017
Offline
Hi, thanks for quick response.

If I make a direct change to “small” prefab that is embedded inside another major prefabs they will also update once I apply the changes - this is standard behavior.
To clarify my HDAs are not making any changes to the small prefab. They just place it in locations of the points generated by the Houdini Engine.

STC
Edited by staszek-c - Oct. 10, 2019 10:27:19
User Avatar
Member
12 posts
Joined: May 2017
Offline
seelan
Does the long prefab update also happen if you make a change directly to the prefab and apply it (i.e. not going through Houdini Engine)?
@seelan Did you tried / manage to recreate the issue?

So far I hacked a walkaround by replacing the prefab placing nodes in HDA definition with simple dummy mesh that's packed and copied to points. After baking the HDA in Unity I run custom script that replaces each dummy with chosen prefab. Although I'd still appreciate some update on this.

STC
Edited by staszek-c - today 10:20:38
  • Quick Links