Jump to content

Reverting overrides on instances


PeteNics

Recommended Posts

Hi. I'm making a tool that uses alot of instancing to assemble a level in Unity. I've come up against some issues with the way Houdini engine overrides lots of properties on each instance that you may not want. You can control a few overrides via the Unity attributes but lots of other attributes will also be overridden. Instead I found it better to revert all the overrides that occur with the instancing so that each prefab can be set correctly upfront. To do this I attach a script via the Unity script attribute which looks a bit like this:
 

    private void GetInstancedOverrides()
    {
        InstancedObjs.Clear();

        foreach (var childTransform in GetComponentsInChildren<Transform>())
        {
            if (childTransform.gameObject.name.Contains("Instance"))
            {
                InstancedObjs.Add(childTransform);
            }
        }

        FixedInstancedOverrides();
    }

    private void FixedInstancedOverrides()
    {
        foreach (var childTransform in InstancedObjs)
        {
#if UNITY_EDITOR
            PrefabUtility.RevertPrefabInstance(childTransform.gameObject, InteractionMode.UserAction);
#endif            
        }
        Debug.Log("Fixup fired");
    }


The issue is this fires to early and breaks rebuilds or recooking of the HDA. i used editor coroutines to delay running these functions which does work but I wanted to ask if there was a good way to latch onto the event of the HDA to say the cook or rebuild had finished?

Edited by PeteNics
Can i get this moved to the Games area instead of the Tools please i feel it is more appropriate there
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...