Can't instantiate and get a referene to the GameObject

// Instantiate required objects
        // Trees
        var treeParent = new GameObject();
        treeParent.name = "Trees";
        foreach(TreeSaveLoad.TreeData tree in gameData.trees)
        {
            var treeType = redwoodTree;
            switch (tree.type)
            {
                case (TreeSaveLoad.TreeType.Redwood):
                    treeType = redwoodTree;
                    continue;
                case (TreeSaveLoad.TreeType.Birch):
                    treeType = birchTree;
                    continue;
                case (TreeSaveLoad.TreeType.Beech):
                    treeType = beechTree;
                    continue;
                case (TreeSaveLoad.TreeType.Pine):
                    treeType = pineTree;
                    continue;
                case (TreeSaveLoad.TreeType.Oak):
                    treeType = oakTree;
                    continue;
                case (TreeSaveLoad.TreeType.Maple):
                    treeType = mapleTree;
                    continue;
            }
            GameObject treeChild = Instantiate(treeType, tree.position, Quaternion.identity) as GameObject;
        }

I have 6 prefabs which are different types of trees. When I instantiate them based on their stored position and type, I want to be able to reference the spawned object in order to place them under an empty parent object “Trees” so that they don’t clutter up the editor view. However, Unity does not let me Instantiate it as a GameObject. How can I get a reference to the instantiated object? Thanks.

The error thrown is “‘Cannot convert UnityEngine.Transform’ to ‘UnityEngine.GameObject’ via a built-in conversion.”

The error thrown is “‘Cannot convert UnityEngine.Transform’ to ‘UnityEngine.GameObject’ via a built-in conversion.”
This is very important! So you instantiate something and get a Transform back, that is not an GameObject. You can cast the result of Instantiate to a Transform though, and then get the gameObject property.

Ok, putting it as a Transform instead of a GameObject works. However, my code does not run because apparently “continue” breaks the foreach loop. Is there a way to exit the switch loop alone?

Thanks for the help!