So since this was really dragging our productivity down, I went and did the legwork to track this down further. My (simplified) setup is a RoomTemplate.hda, which references Probe_proxy.prefab (via an Attribute Create op as above). This is cooked and then baked as separate prefabs (RoomA.prefab / RoomB.prefab / etc.). Certain modifications seem to trigger several full re-import of all baked prefabs (in my case, each one re-imported three times).
I've tracked it down to HEU_PartData.cs / GenerateInstancesFromUnityAssetPathAttribute @ line 880:
HEU_AssetDatabase.ImportAsset(instancePathAttrValues[i], HEU_AssetDatabase.HEU_ImportAssetOptions.Default);
Which is a wrapper around
AssetDatabase.ImportAsset [
docs.unity3d.com]. This triggers a reimport of the Probe_proxy.prefab (which is just a single GameObject with a marker component) *but* then because that's included in the existing baked prefabs (RoomA.prefab etc.) it triggers a reimport of *all* of those. This will happen for each time that the .hda references a unity prefab (which is why I see everything reimported three times in total).
Thoughts:
- Unity could be smarter here. Probe_proxy.prefab is unchanged, yet it ripples through and reimports the room prefabs unnecessarily.
- Houdini could be smarter here and use the batching API [docs.unity3d.com] for asset database changes since we’ll be doing lots in a single operation and that would be much faster.
- But… do we even need the ImportAsset call in the first place? Houdini isn’t modifying it, it just wants it loaded, which it does on the line after with LoadAssetAtPath. Removing the ImportAsset line and things seem to work (and avoids all the unnecessary imports).
- Alternatively, a post-cook script could unpack any created prefabs so they no longer contain nested prefabs. Less than idea since prefab changes won’t propagate, but the least risky and doesn’t involve changing the Houdini plugin. I’ve tested this by manually unpacking and this also works.
Right now I'm going with option 3, because as far as I can see that's safe. Unity will just cache the asset itself like normal and we never need to force a reimport. But it'd be good to get some more eyes on it that are more familiar with the plugin code.
(Aside: thanks for including the source to the Unity plugin, otherwise tracking this down would have been impossible.
)