/// 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();
        }
        public override void DrawSection()
        {
            repaint = false;

            using (new HorizontalCenteredScope())
            {
                GUILayout.Box(EUIResourceManager.Instance.GetContent("Blockout Logo"), EUIResourceManager.Instance.Skin.GetStyle("Texture"), GUILayout.Width(BlockoutEditorSettings.OneColumnWidth), GUILayout.Height(120));
            }

            if (GUILayout.Button(EUIResourceManager.Instance.GetContent("Create Hierarchy"), GUILayout.Height(EditorGUIUtility.singleLineHeight * 6), GUILayout.Width(BlockoutEditorSettings.OneColumnWidth)))
            {
                if (!BlockoutStaticFunctions.FindHeirachy(ref blockoutHierarchy))
                {
                    if (EditorSceneManager.SaveOpenScenes())
                    {
                        using (new UndoScope("Create Blockout Hierarchy"))
                        {
                            blockoutHierarchy.root = new GameObject("Blockout").transform;
                            Undo.RegisterCreatedObjectUndo(blockoutHierarchy.root.gameObject, "");
                            blockoutHierarchy.root.gameObject.AddComponent <BlockoutCommentInGameGUI>();
                            blockoutHierarchy.root.gameObject.AddComponent <Notepad>();
                            var section = blockoutHierarchy.root.gameObject.AddComponent <BlockoutSection>();
                            section.Section = SectionID.Root;
                            BlockoutStaticFunctions.CreateBlockoutSubHeirachyWithRoot(blockoutHierarchy.root);
                            BlockoutStaticFunctions.FindHeirachy(ref blockoutHierarchy);
                            BlockoutStaticFunctions.TryLoadSceneDefinitions();
                        }
                    }
                    else
                    {
                        EditorUtility.DisplayDialog("Blockout Editor Error", "You need to have a SAVED scene before using the Blockout system", "OK");
                    }
                }
            }

            GUILayout.Space(5);
            GUILayout.Label(EUIResourceManager.Instance.GetContent("Intro Label"));
            GUILayout.Space(5);

            if (newVersion != BlockoutEditorSettings.VERSION)
            {
                GUILayout.Space(5);
                using (new HorizontalCenteredScope())
                {
                    GUILayout.Label("New Version Available (" + newVersion + ")", EditorStyles.boldLabel,
                                    GUILayout.Height(EditorGUIUtility.singleLineHeight * 2));
                }

                GUILayout.Space(5);
            }

            GUILayout.Label(EUIResourceManager.Instance.GetContent("Example Scenes"), GUILayout.Width(390), GUILayout.Height(EditorGUIUtility.singleLineHeight * 2));
            if (GUILayout.Button(EUIResourceManager.Instance.GetContent("All Assets"), GUILayout.Width(390),
                                 GUILayout.Height(EditorGUIUtility.singleLineHeight * 3 + 8)))
            {
                EditorSceneManager.OpenScene("Assets/Blockout/Examples/All Assets.unity");
            }

            using (new HorizontalCenteredScope())
            {
                if (GUILayout.Button(EUIResourceManager.Instance.GetContent("FPS Scene"), GUILayout.Width(193), GUILayout.Height(125)))
                {
                    EditorSceneManager.OpenScene("Assets/Blockout/Examples/FPS.unity");
                }
                if (GUILayout.Button(EUIResourceManager.Instance.GetContent("Rollerball Scene"), GUILayout.Width(193), GUILayout.Height(125)))
                {
                    EditorSceneManager.OpenScene("Assets/Blockout/Examples/Rollerball.unity");
                }
            }

            GUILayout.Space(5);

            GUILayout.Label("Keyboard Shortcuts");

            using (new GUILayout.HorizontalScope())
            {
                if (Application.platform == RuntimePlatform.WindowsEditor)
                {
                    GUILayout.Label("Ctrl + ALT + B", EditorStyles.boldLabel, GUILayout.Width(152));
                    GUILayout.Label("Show The Blockout Window");
                }
                else
                {
                    GUILayout.Label("Cmd + ALT + B", EditorStyles.boldLabel, GUILayout.Width(152));
                    GUILayout.Label("Show / Hide The Blockout Window");
                }
            }

            using (new GUILayout.HorizontalScope())
            {
                GUILayout.Label("Alt + S", EditorStyles.boldLabel, GUILayout.Width(152));
                GUILayout.Label("Toggle Auto Grid Snapping");
            }

            using (new GUILayout.HorizontalScope())
            {
                GUILayout.Label("Alt + C", EditorStyles.boldLabel, GUILayout.Width(152));
                GUILayout.Label("Toggle Comments");
            }

            using (new GUILayout.HorizontalScope())
            {
                GUILayout.Label("Alt + Z", EditorStyles.boldLabel, GUILayout.Width(152));
                GUILayout.Label("Decrease Grid Snapping Value");
            }

            using (new GUILayout.HorizontalScope())
            {
                GUILayout.Label("Alt + X", EditorStyles.boldLabel, GUILayout.Width(152));
                GUILayout.Label("Increase Grid Snapping Value");
            }

            using (new GUILayout.HorizontalScope())
            {
                GUILayout.Label("End", EditorStyles.boldLabel, GUILayout.Width(152));
                GUILayout.Label("Snap to ground (-Y)");
            }

            using (new GUILayout.HorizontalScope())
            {
                GUILayout.Label("L", EditorStyles.boldLabel, GUILayout.Width(152));
                GUILayout.Label("Toggle Locked Assets");
            }

            using (new GUILayout.HorizontalScope())
            {
                GUILayout.Label("G", EditorStyles.boldLabel, GUILayout.Width(152));
                GUILayout.Label("Jump To Selected Prefab In Project");
            }

            using (new GUILayout.HorizontalScope())
            {
                GUILayout.Label("C (Hold)", EditorStyles.boldLabel, GUILayout.Width(152));
                GUILayout.Label("(Hold) Show Scroll Picker");
            }

            using (new GUILayout.HorizontalScope())
            {
                GUILayout.Label("", EditorStyles.boldLabel, GUILayout.Width(152));
                GUILayout.Label("(Release) Confirm Swap");
            }

            using (new GUILayout.HorizontalScope())
            {
                GUILayout.Label("Space", EditorStyles.boldLabel, GUILayout.Width(152));
                GUILayout.Label("Scrollpicker: Spawn Selected Asset");
            }

            using (new GUILayout.HorizontalScope())
            {
                GUILayout.Label("", EditorStyles.boldLabel, GUILayout.Width(152));
                GUILayout.Label("Quickpicker: Show / Select Item");
            }
            using (new GUILayout.HorizontalScope())
            {
                GUILayout.Label("Arrow Keys", EditorStyles.boldLabel, GUILayout.Width(152));
                GUILayout.Label("Quickpicker: Change selection");
            }

            GUILayout.Space(5);


            using (new GUILayout.HorizontalScope())
            {
                if (GUILayout.Button(EUIResourceManager.Instance.GetContent("Open Documentation"), GUILayout.Width(193),
                                     GUILayout.Height(EditorGUIUtility.singleLineHeight * 3 + 8)))
                {
                    BlockoutStaticFunctions.OpenDocumentation();
                }
                if (GUILayout.Button(EUIResourceManager.Instance.GetContent("Open Tutorials"), GUILayout.Width(193),
                                     GUILayout.Height(EditorGUIUtility.singleLineHeight * 3 + 8)))
                {
                    BlockoutStaticFunctions.OpenTutorials();
                }
            }

            GUILayout.Space(5);

            if (GUILayout.Button(EUIResourceManager.Instance.GetContent("Feedback"), GUILayout.Width(390), GUILayout.Height(EditorGUIUtility.singleLineHeight * 3 + 8)))
            {
                BlockoutStaticFunctions.SubmitBugReport();
            }

            GUILayout.Space(10);

            using (new HorizontalCenteredScope())
            {
                GUILayout.Box(EUIResourceManager.Instance.GetContent("Radical Forge Logo"), EUIResourceManager.Instance.Skin.GetStyle("Texture"), GUILayout.Width(150),
                              GUILayout.Height(45));
            }
        }
        /// <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);
            }
        }