Unity: Transform has SetIsDispatchInterested present

If you’re getting the Unity assert: “Assertion failed: Transform has SetIsDispatchInterested present when destroying the hierarchy. Systems must deregister themselves in Deactivate.”

This error is corrected in Unity 2017.3.1p3 (or above). This is happening whenever a collider is disabled on a GameObject which is not currently activeInHierarchy.

 

 

 

Advertisement

Unity: Run an action on all children of a gameobject

Handy piece of code that will run an action on all children of a gameobject.

using System;
using UnityEngine;

public static class UnityExtensions
{
    /// <summary>
    /// Run an action on all children of a gameobject
    /// </summary>
    public static void RunOnChildrenRecursive(this GameObject a_go, Action<GameObject> a_action)
    {
         foreach (var child in a_go.GetComponentsInChildren<Transform>(true))
             a_action(child.gameObject);
    }
}

To use it, do something like this: –

 myGameObject.RunOnChildrenRecursive(child => child.layer = LayerMask.NameToLayer("UI3D"));