HDA instancing prefabs question

   2614   2   1
User Avatar
Member
12 posts
Joined: May 2017
Offline
Hello,
I've searched the forum but I did not manage to find information about that.
I can add Unity prefabs for the scatter/placement tool:



but after the bake I get game objects that are not link to the original prefab:



which makes it complicated to work with when prefab changes.

Is it possible to instantiate prefabs and maintain the link to the original?
Same way the PrefabUtility.InstantiatePrefab method does that when used in Unity C# scripts?

I'd appreciate pointing me in the right direction and information if that's doable or do I have to add workaround scripts inside Unity.

Cheers,
ST

Attachments:
1.png (14.1 KB)
2.png (109.6 KB)

User Avatar
Member
571 posts
Joined: May 2017
Offline
This is because of how you are supplying the input object. The input object in this case has its geometry uploaded into Houdini, processed during cook, and then output as a separate object. As its a separate and new object, there is no prefab connection to the original. To work around this and if you don't need to change the input object, then you can simply use instancing via the asset path name. The simplest way to do this is to output points only and set string attribute with name “unity_instance”.
See attribute info here: https://www.sidefx.com/docs/unity/_instancing.html#ObjectInstancers_Attribute [www.sidefx.com]

If you do need to change the input object and create a new object, then I suggest you break the HDA into 2 HDAs. First one takes in an input object and generates a prefab object. Second one generates points with path to the prefab. This will maintain the prefab link even after baking, as long you always update the same prefab using your first HDA.
User Avatar
Member
12 posts
Joined: May 2017
Offline
Thanks for the explanation. Worked like a charm.
As a bonus since I'm using Unity 2019+ then by baking HDA's results into prefab I get nested prefab.



Cheers!
ST
Edited by staszek-c - May 14, 2019 11:02:40

Attachments:
1.png (177.3 KB)

  • Quick Links