private IRigEffectorHolder FetchRigEffectorHolder(Transform transform)
        {
            var rigBuilder = EditorHelper.GetClosestComponent <RigBuilder>(transform);
            var rig        = EditorHelper.GetClosestComponent <Rig>(transform, (rigBuilder != null) ? rigBuilder.transform : null);

            if (rigBuilder.ContainsEffector(transform))
            {
                return(rigBuilder);
            }
            else if (rig.ContainsEffector(transform))
            {
                return(rig);
            }

            return(null);
        }
        static IRigEffectorOverlay FetchOrCreateEffectorOverlay()
        {
            Transform[] transforms         = Selection.GetTransforms(SelectionMode.ExcludePrefab | SelectionMode.Editable);
            var         inspectedEffectors = new List <ScriptableObject>();

            for (int i = 0; i < s_ActiveEffectors.Count; ++i)
            {
                var effector = s_ActiveEffectors[i];
                if (effector != null && effector.transform != null)
                {
                    if (Selection.Contains(effector.transform) || Selection.Contains(effector.transform.gameObject))
                    {
                        inspectedEffectors.Add(s_ActiveEffectors[i]);
                    }
                }
            }

            if (inspectedEffectors.Count > 0)
            {
                var overlay = new RigEffectorOverlay();
                overlay.Initialize(new SerializedObject(inspectedEffectors.ToArray()));

                s_ActiveOverlay = overlay;
            }
            else
            {
                RigEffectorWizard wizard = null;

                foreach (var transform in transforms)
                {
                    RigBuilder         rigBuilder = EditorHelper.GetClosestComponent <RigBuilder>(transform);
                    Rig                rig        = EditorHelper.GetClosestComponent <Rig>(transform, (rigBuilder != null) ? rigBuilder.transform : null);
                    IRigEffectorHolder holder     = (rig != null) ? (IRigEffectorHolder)rig : (IRigEffectorHolder)rigBuilder;

                    if (holder == null)
                    {
                        continue;
                    }

                    if (wizard == null)
                    {
                        wizard = new RigEffectorWizard();
                    }

                    wizard.Add(holder, transform);
                }

                if (wizard != null)
                {
                    s_ActiveOverlay = wizard;
                }
                else
                {
                    s_ActiveOverlay = null;
                }
            }

            s_ActiveSelection = transforms;

            return(s_ActiveOverlay);
        }