Jump to content
PeteNics

Reverting overrides on instances

Recommended Posts

Posted (edited)

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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×