/// Apply a new parent transform to the target gameobjects
        /// <param name="targets"> The gameobjects to reparent</param>
        /// <param name="blockoutSection"> The new section that it needs to find in the level above to parent to</param>
        private void ApplyParentTransformFromSection(GameObject[] targets, SectionID blockoutSection)
        {
            for (var i = 0; i < targets.Length; ++i)
            {
                var vl = targets[i].GetComponentsInParent <BlockoutSection>().Where(x => x.Section == SectionID.Root)
                         .ToList();

                var localRoot = vl.Count > 0 ? vl[0].gameObject : blockoutHierarchy.root.gameObject;
                BlockoutStaticFunctions.CreateBlockoutSubHeirachyWithRoot(localRoot.transform, localRoot.name + "_");

                var targetTransform = localRoot.GetComponentsInChildren <BlockoutSection>()
                                      .Where(x => x.Section == blockoutSection)
                                      .ToList()[0].transform;

                targets[i].transform.SetParent(targetTransform);

                BlockoutStaticFunctions.TrimTargetBlockoutHierarchy(localRoot);
            }
            BlockoutStaticFunctions.ApplyCurrentTheme();
        }
        /// <summary>
        ///     Reparents and gameobject within the bounds of target object.
        /// </summary>
        /// <param name="targetObject">The target object.</param>
        /// <param name="target">The target.</param>
        private void ReparentToBoundsContent(GameObject targetObject, Bounds target)
        {
            using (new UndoScope("Reparent Objects to comment"))
            {
                var allObjects = FindObjectsOfType <GameObject>().Select(x => x.transform).Where(
                    x =>
                {
                    if (x.GetComponent <
                            BlockoutSection
                            >())
                    {
                        return(false);
                    }
                    if (x.parent == null
                        )
                    {
                        return(false);
                    }
                    if (x.parent ==
                        targetObject)
                    {
                        return(false);
                    }
                    if (x
                        .parent
                        .GetComponent <
                            BlockoutSection
                            >())
                    {
                        return(true);
                    }
                    return(false);
                }
                    ).ToArray();
                if (!targetObject.GetComponent <BlockoutSection>())
                {
                    targetObject.AddComponent <BlockoutSection>().Section = SectionID.Root;
                }
                BlockoutStaticFunctions.CreateBlockoutSubHeirachyWithRoot(targetObject.transform,
                                                                          targetObject.name + "_");

                Undo.RecordObjects(allObjects, "Reparent Objects");

                for (var i = 0; i < allObjects.Length; ++i)
                {
                    Bounds colliderBounds;
                    if (allObjects[i].GetComponent <Collider>())
                    {
                        colliderBounds = allObjects[i].GetComponent <Collider>().bounds;
                    }
                    else if (allObjects[i].GetComponent <Renderer>())
                    {
                        colliderBounds = allObjects[i].GetComponent <Renderer>().bounds;
                    }
                    else
                    {
                        continue;
                    }

                    if (target.Contains(colliderBounds.max) && target.Contains(colliderBounds.min))
                    {
                        var section = allObjects[i].transform.parent.GetComponent <BlockoutSection>();
                        if (section)
                        {
                            BlockoutStaticFunctions.ReparentObjectToTargetRoot(allObjects[i].transform,
                                                                               targetObject.transform);
                        }
                    }
                }

                BlockoutStaticFunctions.TrimTargetBlockoutHierarchy(targetObject);
            }
        }