Duplication bugs are driving our level designers insane

   3254   3   2
User Avatar
Member
12 posts
Joined: Jan. 2020
Offline
Copy & pasting (or Ctrl-D) duplicating) a HDA instance in Unity doesn’t work, and it causes the HDA instances to break in lots of weird and unpredictable ways. Yes, I know the documentation says:

Note that using the built-in duplicate or copy/paste mechanisms in Unity on the asset will not work properly

But after using HDAs in our workflow for several months, I’ve come to the conclusion that this limitation is absolutely crippling our use of Houdini, to the point of making it useless. Yes, I know there’s a ‘Duplicate Asset’ button, but that doesn’t actually solve the workflow issues.

The problem:
Pasting a HDA instance breaks *both* instances - the original and the new copy. Parameters may or may not work depending on instance, the curves editor is highly confused, cooking often updates the wrong asset.
Saving and reopening a scene after a HDA has been pasted causes different breakage behaviour. This makes it difficult to establish which/where HDAs have broken.
Breakage occurs silently. That means a HDA can be accidentally pasted by one designer and checked in, only for another designer to find that the HDAs are broken and not know why.
The ‘duplicate asset’ button goes against the normal Unity workflow. Designers are (quite reasonably) expecting copy&paste to work.
It’s really easy to accidentally copy&paste a HDA without realising it, especially HDAs are nested inside other objects or multiple people working on a scene. It’s not reasonable for users to manually inspect *every* object within a hierarchy before pressing ctrl-c / ctrl-v.
Once a HDA instance is broken, there doesn’t seem to be a way to fix it other than deleting it and starting again. Which means re-adding it and tediously re-creating all the parameters(see 7) and curves (see 8).
Recreating parameters is highly error prone, since unlike normal components they can’t be copy and pasted across to the new instance, but must be manually adjusted one by one.
Recreating curves is even worse, since there’s no raw values exposed, so they have to be redrawn from scratch. Which makes it basically impossible to duplicate the exact same curve.

This basically makes HDAs unusable within Unity - our workaround workflow is to bring each HDA into it’s own scene, set the parameters and bake it into a prefab. Then use the non-HDA prefab everywhere. This is:
Slow and error prone
Creates a lot of file system noise - it adds a lot of asset files to the project that wouldn’t normally exist and have to be uniquely named and managed
Doesn’t really support unique per-instance HDAs
Makes editing the HDA instances tedious rather than just adjusting the parameters in-place.

While this works, at this point we might as well just be exporting static fbx files from Houdini. Which defeats the whole point of using Houdini and HDAs in the first place.

Possible Solutions

Ok, so Unity doesn’t provide explicit copy/paste/duplicate events. That sucks, but this is too important so let’s have a look at how to fix it.

ValidateCommand
https://docs.unity3d.com/ScriptReference/EventType.ValidateCommand.html [docs.unity3d.com]
Allegedly sends paste/duplicate events, but after hacking around with it for a little while, I couldn’t get this to actually send events for a HDA instance.

Monitoring InstanceId

Getting HoudiniAssetRoot to monitor it’s instanceId and see when it’s changed reliably catches copy/paste/duplicate events:

[SerializeField]
        private int cachedInstanceId = 0;

        private void Awake()
        {
            // Note these need the component to be tagged as [ExecuteInEditMode]

            if (this.cachedInstanceId == 0)
            {
                // No cached instance id set. Either:
                //    This component is just being created from scratch (which might be via HEU_HoudiniAsset::Duplicate)
                //    Or this is an old component (before cachedInstanceId was added) being loaded from disk
                Debug.Log("Fresh asset root Awake for " + this.gameObject.name);
            }
            else if (this.cachedInstanceId != this.GetInstanceID())
            {
                // Instance id has changed. Either:
                //    This object is the output of a paste/duplicate command
                //    We're an existing component with a valid cached id which is being reloaded from disk (eg. scene opening)
                Debug.Log("Awake - instance id changed for " + this.gameObject.name);
            }
            this.cachedInstanceId = this.GetInstanceID();
        }

So now we just need to figure out which state needs to be reinitialised for the clone.
It looks like the assetId, asset cache folder path and the ‘b force update’ don’t update correctly, but I’m not sure on how to refresh these internally.

Sorry for the wall of text, it’s been driving our designers crazy and this is the first I’ve been able to sit down and work through it. Any help fixing it (or getting it fixed in the plugin) as a matter of urgency would be really appreciated.

Platform: Windows 10
Houdini version: 18.0.348
Houdini engine: 3.3.2
HOUDINI_PLUGIN_VERSION = 2
Edited by OrangyTang - Jan. 18, 2021 13:45:11
User Avatar
Member
9 posts
Joined: Feb. 2018
Offline
I'm also digging into this now for the same reasons, studio is considering Houdini but these kinds of issues are not good for workflow in a large team & it isn't in line with the standard expected Unity editor behaviour.

Have you found any leads?

For my simple test case for stepping through the code with a debugger, I'm just using the Boolean tool from the default shelf in the Houdini Tools editor window.

It's easy to repro, once you duplicate a "setup" (the HDA and its hierarchy of gameobjects in the scene), the duplicated HDA will no longer bake correctly when changing the boolean operation.
Edited by xra - March 4, 2021 03:27:31
User Avatar
Member
12 posts
Joined: Jan. 2020
Offline
I actually raised this as a proper bug report and after some back and forth sideFx fixed this, so that's nice. If you install the latest daily build that should have the fix in it.

Disclaimer - I've only lightly tested the fix so if you still get issues I totally recommend filing it as a bug for your use case.
User Avatar
Member
100 posts
Joined: Dec. 2020
Offline
Hi, indeed this was looked at, and we added partial support for it in Houdini 18.5.483. To my knowledge, we don't have full control over what happens when Unity duplicates an object, so I wouldn't consider it an "officially supported" yet. Use the "Duplicate" button for a foolproof duplication method.

However, if you can find a bug with copy/pasting HDAs, please submit a bug report with an example HDA in https://www.sidefx.com/forum/topic/38188/ [www.sidefx.com] .
  • Quick Links