private static void ExportDaeFile(MenuCommand menuCommand)
        {
            var objectTarget = menuCommand.context as VoxelChunksObject;

            if (objectTarget == null)
            {
                return;
            }

            var objectCore = new VoxelChunksObjectCore(objectTarget);

            string path = EditorUtility.SaveFilePanel("Export COLLADA(dae) File", objectCore.GetDefaultPath(), string.Format("{0}.dae", Path.GetFileNameWithoutExtension(objectTarget.voxelFilePath)), "dae");

            if (string.IsNullOrEmpty(path))
            {
                return;
            }

            if (!objectCore.ExportDaeFile(path))
            {
                Debug.LogErrorFormat("<color=green>[Voxel Importer]</color> Export COLLADA(dae) File error. file:{0}", path);
            }
        }
        private static void SaveAllUnsavedAssets(MenuCommand menuCommand)
        {
            var objectTarget = menuCommand.context as VoxelChunksObject;

            if (objectTarget == null)
            {
                return;
            }

            var objectCore = new VoxelChunksObjectCore(objectTarget);

            var folder = EditorUtility.OpenFolderPanel("Save all", objectCore.GetDefaultPath(), null);

            if (string.IsNullOrEmpty(folder))
            {
                return;
            }
            if (folder.IndexOf(Application.dataPath) < 0)
            {
                EditorCommon.SaveInsideAssetsFolderDisplayDialog();
                return;
            }

            Undo.RecordObject(objectTarget, "Save All Unsaved Assets");
            if (objectTarget.chunks != null)
            {
                Undo.RecordObjects(objectTarget.chunks, "Save All Unsaved Assets");
            }

            if (objectTarget.materialMode == VoxelChunksObject.MaterialMode.Combine)
            {
                #region Material
                if (objectTarget.materials != null)
                {
                    for (int index = 0; index < objectTarget.materials.Count; index++)
                    {
                        if (objectTarget.materials[index] == null || EditorCommon.IsMainAsset(objectTarget.materials[index]))
                        {
                            continue;
                        }
                        var path = folder + "/" + string.Format("{0}_mat{1}.mat", objectTarget.gameObject.name, index);
                        path = FileUtil.GetProjectRelativePath(path);
                        path = AssetDatabase.GenerateUniqueAssetPath(path);
                        AssetDatabase.CreateAsset(Material.Instantiate(objectTarget.materials[index]), path);
                        objectTarget.materials[index] = AssetDatabase.LoadAssetAtPath <Material>(path);
                    }
                }
                #endregion

                #region Texture
                if (objectTarget.atlasTexture != null && !EditorCommon.IsMainAsset(objectTarget.atlasTexture))
                {
                    var path = folder + "/" + string.Format("{0}_tex.png", objectTarget.gameObject.name);
                    path = EditorCommon.GenerateUniqueAssetFullPath(path);
                    File.WriteAllBytes(path, objectTarget.atlasTexture.EncodeToPNG());
                    path = FileUtil.GetProjectRelativePath(path);
                    AssetDatabase.ImportAsset(path);
                    objectCore.SetTextureImporterSetting(path, objectTarget.atlasTexture);
                    objectTarget.atlasTexture = AssetDatabase.LoadAssetAtPath <Texture2D>(path);
                }
                #endregion

                if (objectTarget.chunks != null)
                {
                    for (int i = 0; i < objectTarget.chunks.Length; i++)
                    {
                        if (objectTarget.chunks[i] == null)
                        {
                            continue;
                        }
                        #region Mesh
                        if (objectTarget.chunks[i].mesh != null && !EditorCommon.IsMainAsset(objectTarget.chunks[i].mesh))
                        {
                            var path = folder + "/" + string.Format("{0}_{1}_mesh.asset", objectTarget.gameObject.name, objectTarget.chunks[i].chunkName);
                            path = FileUtil.GetProjectRelativePath(path);
                            path = AssetDatabase.GenerateUniqueAssetPath(path);
                            AssetDatabase.CreateAsset(Mesh.Instantiate(objectTarget.chunks[i].mesh), path);
                            objectTarget.chunks[i].mesh = AssetDatabase.LoadAssetAtPath <Mesh>(path);
                        }
                        #endregion
                    }
                }
            }
            else if (objectTarget.materialMode == VoxelChunksObject.MaterialMode.Individual)
            {
                if (objectTarget.chunks != null)
                {
                    for (int i = 0; i < objectTarget.chunks.Length; i++)
                    {
                        if (objectTarget.chunks[i] == null)
                        {
                            continue;
                        }
                        #region Mesh
                        if (objectTarget.chunks[i].mesh != null && !EditorCommon.IsMainAsset(objectTarget.chunks[i].mesh))
                        {
                            var path = folder + "/" + string.Format("{0}_{1}_mesh.asset", objectTarget.gameObject.name, objectTarget.chunks[i].chunkName);
                            path = FileUtil.GetProjectRelativePath(path);
                            path = AssetDatabase.GenerateUniqueAssetPath(path);
                            AssetDatabase.CreateAsset(Mesh.Instantiate(objectTarget.chunks[i].mesh), path);
                            objectTarget.chunks[i].mesh = AssetDatabase.LoadAssetAtPath <Mesh>(path);
                        }
                        #endregion

                        #region Material
                        if (objectTarget.chunks[i].materials != null)
                        {
                            for (int index = 0; index < objectTarget.chunks[i].materials.Count; index++)
                            {
                                if (objectTarget.chunks[i].materials[index] == null || EditorCommon.IsMainAsset(objectTarget.chunks[i].materials[index]))
                                {
                                    continue;
                                }
                                var path = folder + "/" + string.Format("{0}_{1}_mat{2}.mat", objectTarget.gameObject.name, objectTarget.chunks[i].chunkName, index);
                                path = FileUtil.GetProjectRelativePath(path);
                                path = AssetDatabase.GenerateUniqueAssetPath(path);
                                AssetDatabase.CreateAsset(Material.Instantiate(objectTarget.chunks[i].materials[index]), path);
                                objectTarget.chunks[i].materials[index] = AssetDatabase.LoadAssetAtPath <Material>(path);
                            }
                        }
                        #endregion

                        #region Texture
                        if (objectTarget.chunks[i].atlasTexture != null && !EditorCommon.IsMainAsset(objectTarget.chunks[i].atlasTexture))
                        {
                            var path = folder + "/" + string.Format("{0}_{1}_tex.png", objectTarget.gameObject.name, objectTarget.chunks[i].chunkName);
                            path = EditorCommon.GenerateUniqueAssetFullPath(path);
                            File.WriteAllBytes(path, objectTarget.chunks[i].atlasTexture.EncodeToPNG());
                            path = FileUtil.GetProjectRelativePath(path);
                            AssetDatabase.ImportAsset(path);
                            objectCore.SetTextureImporterSetting(path, objectTarget.chunks[i].atlasTexture);
                            objectTarget.chunks[i].atlasTexture = AssetDatabase.LoadAssetAtPath <Texture2D>(path);
                        }
                        #endregion
                    }
                }
            }
            else
            {
                Assert.IsTrue(false);
            }

            objectCore.ReCreate();
            InternalEditorUtility.RepaintAllViews();
        }