//
        private LevelFile createLevelData(string levelName)
        {
            Transform parent = LevelEditor.Instance.curLevelChunk.trfmCubes;

            if (parent == null)
            {
                return(null);
            }

            LevelFile levelFile = new LevelFile();

            levelFile.fileFormatVersion = Globals.levelSaveFormatVersion;

            levelFile.levelId   = -1;
            levelFile.levelName = levelName;

            levelFile.levelPos   = new DataTypeVector3();
            levelFile.levelPos.x = 0;
            levelFile.levelPos.y = 0;
            levelFile.levelPos.z = 0;

            levelFile.playerPosition   = new DataTypeVector3();
            levelFile.playerPosition.x = FlyCam.Instance.player.position.x;
            levelFile.playerPosition.y = FlyCam.Instance.player.position.y;
            levelFile.playerPosition.z = FlyCam.Instance.player.position.z;

            levelFile.playerEuler   = new DataTypeVector3();
            levelFile.playerEuler.x = FlyCam.Instance.player.eulerAngles.x;
            levelFile.playerEuler.y = FlyCam.Instance.player.eulerAngles.y;
            levelFile.playerEuler.z = FlyCam.Instance.player.eulerAngles.z;

            levelFile.levelQuadrants = new List <LevelQuadrant> ();

            foreach (Transform child in parent)
            {
                if (!child.gameObject.activeSelf)
                {
                    continue;
                }

                LevelQuadrant quadrant = new LevelQuadrant();

                quadrant.position   = new DataTypeVector3();
                quadrant.position.x = child.localPosition.x;
                quadrant.position.y = child.localPosition.y;
                quadrant.position.z = child.localPosition.z;

                int qX = (int)quadrant.position.x;
                int qY = (int)quadrant.position.y;
                int qZ = (int)quadrant.position.z;

                // sanity check!
                bool isEdgeQuadrant = ((qX <= -1 || qY <= -1 || qZ <= -1) || (qX >= Globals.LEVEL_WIDTH || qY >= Globals.LEVEL_HEIGHT || qZ >= Globals.LEVEL_DEPTH));
                if (isEdgeQuadrant)
                {
                    continue;
                }

                //quadrant.isEdge = (isEdgeQuadrant ? 1 : 0);

                quadrant.levelObjects = new List <LevelObject> ();

                Transform container = child.Find("container");
                if (container != null)
                {
                    string materialName;

                    foreach (Transform cube in container)
                    {
                        //if (!cube.gameObject.activeSelf) {
                        //	continue;
                        //}

                        LevelObject cubeObject = new LevelObject();

                        cubeObject.isActive   = (cube.gameObject.activeSelf ? 1 : 0);
                        cubeObject.materialId = 0;

                        //cubeObject.name = cube.name;
                        //Debug.Log ("    ->cube "+cubeObject.name);

                        /*cubeObject.position   = new DataTypeVector3 ();
                         * cubeObject.position.x = cube.localPosition.x;
                         * cubeObject.position.y = cube.localPosition.y;
                         * cubeObject.position.z = cube.localPosition.z;*/

                        if (cubeObject.isActive == 1)
                        {
                            if (isEdgeQuadrant)
                            {
                                cubeObject.materialId = -1;
                            }
                            else
                            {
                                MeshRenderer renderer = cube.GetComponent <MeshRenderer> ();
                                if (renderer != null)
                                {
                                    materialName          = renderer.material.name.Replace(" (Instance)", "");
                                    cubeObject.materialId = Array.IndexOf(Globals.materials, materialName);
                                }
                            }
                        }

                        quadrant.levelObjects.Add(cubeObject);
                    }
                }

                levelFile.levelQuadrants.Add(quadrant);
            }

            // PROPS

            List <LevelProp> levelProps = new List <LevelProp> ();

            Dictionary <GameObject, worldProp> worldProps = LevelEditor.Instance.curLevelChunk.worldProps;

            foreach (KeyValuePair <GameObject, worldProp> p in worldProps)
            {
                worldProp prop = p.Value;

                if (!prop.go.activeSelf)
                {
                    continue;
                }

                int propId = prop.id;
                if (propId <= 0)
                {
                    continue;
                }

                LevelProp levelProp = new LevelProp();
                levelProp.id = propId;
                //levelProp.name = prop.name;

                levelProp.position   = new DataTypeVector3();
                levelProp.position.x = prop.go.transform.position.x;
                levelProp.position.y = prop.go.transform.position.y;
                levelProp.position.z = prop.go.transform.position.z;

                levelProp.rotation   = new DataTypeQuaternion();
                levelProp.rotation.w = prop.go.transform.rotation.w;
                levelProp.rotation.x = prop.go.transform.rotation.x;
                levelProp.rotation.y = prop.go.transform.rotation.y;
                levelProp.rotation.z = prop.go.transform.rotation.z;

                levelProps.Add(levelProp);
            }

            levelFile.levelProps = levelProps;

            /*parent = LevelEditor.Instance.goProps;
             * if (parent != null) {
             *
             *      List<LevelProp> levelProps = new List<LevelProp> ();
             *
             *      foreach (Transform prop in parent.transform) {
             *
             *              if (!prop.gameObject.activeSelf) {
             *                      continue;
             *              }
             *
             *              int propId = -1;//Globals.getItemIndexFromName (item.name);
             *              if (propId == -1) {
             *                      continue;
             *              }
             *
             *              LevelProp levelProp = new LevelProp ();
             *              levelProp.id   = propId;
             *              levelProp.name = prop.name;
             *
             *              levelProp.position   = new DataTypeVector3 ();
             *              levelProp.position.x = prop.position.x;
             *              levelProp.position.y = prop.position.y;
             *              levelProp.position.z = prop.position.z;
             *
             *              levelProp.rotation = new DataTypeQuaternion ();
             *              levelProp.rotation.w = prop.rotation.w;
             *              levelProp.rotation.x = prop.rotation.x;
             *              levelProp.rotation.y = prop.rotation.y;
             *              levelProp.rotation.z = prop.rotation.z;
             *
             *              levelProps.Add (levelProp);
             *      }
             *
             *      levelFile.levelProps = levelProps;
             * }*/

            return(levelFile);
        }