ILayout.LabelField(string.Empty, GUILayout.MaxWidth(UnityEditor.EditorGUIUtility.labelWidth));

                            using (new AmazingAssets.EditorGUIUtility.EditorGUILayoutBeginVertical())
                            {
                                int buttonsCountHorizontal = 4;

                                Rect rc1 = EditorGUILayout.GetControlRect();
                                Rect rc4 = EditorGUILayout.GetControlRect();
                                rc4 = EditorGUILayout.GetControlRect();

                                Rect position = new Rect(rc1.xMin, rc1.yMin, rc1.width, (rc4.yMax - rc1.yMin));


                                Rect[] rectArray = CalcButtonRects(position, generateMeshOptimizeNames, buttonsCountHorizontal);

                                int i = 0;
                                generateMeshOptimizeUV0 = GUI.Toggle(rectArray[i], generateMeshOptimizeUV0, generateMeshOptimizeNames[i], "Button");
                                generateMeshOptimizeUV2 = GUI.Toggle(rectArray[++i], generateMeshOptimizeUV2, generateMeshOptimizeNames[i], "Button");
                                generateMeshOptimizeUV3 = GUI.Toggle(rectArray[++i], generateMeshOptimizeUV3, generateMeshOptimizeNames[i], "Button");

                                using (new AmazingAssets.EditorGUIUtility.GUIEnabled(false))    //Wireframe data is save here. Always On
                                {
                                    GUI.Toggle(rectArray[++i], true, generateMeshOptimizeNames[i], "Button");
                                }

                                generateMeshOptimizeUV5 = GUI.Toggle(rectArray[++i], generateMeshOptimizeUV5, generateMeshOptimizeNames[i], "Button");
                                generateMeshOptimizeUV6 = GUI.Toggle(rectArray[++i], generateMeshOptimizeUV6, generateMeshOptimizeNames[i], "Button");
                                generateMeshOptimizeUV7 = GUI.Toggle(rectArray[++i], generateMeshOptimizeUV7, generateMeshOptimizeNames[i], "Button");
                                generateMeshOptimizeUV8 = GUI.Toggle(rectArray[++i], generateMeshOptimizeUV8, generateMeshOptimizeNames[i], "Button");

                                generateMeshOptimizeNormal = GUI.Toggle(rectArray[++i], generateMeshOptimizeNormal, generateMeshOptimizeNames[i], "Button");
                                generateMeshOptimizeTangent = GUI.Toggle(rectArray[++i], generateMeshOptimizeTangent, generateMeshOptimizeNames[i], "Button");
                                generateMeshOptimizeColor = GUI.Toggle(rectArray[++i], generateMeshOptimizeColor, generateMeshOptimizeNames[i], "Button");
                                generateMeshOptimizeSkin = GUI.Toggle(rectArray[++i], generateMeshOptimizeSkin, generateMeshOptimizeNames[i], "Button");
                            }
                        }
                    }

                    bool canReplaceSceneMeshes = true;
                    if (generateMeshSaveLocation == SAVE_LOCATION.CustomFolder)
                        canReplaceSceneMeshes = EditorUtilities.IsPathProjectRelative(generateMeshSaveFolderCustomPath);

                    if (canReplaceSceneMeshes)
                        generateMeshReplaceSceneMeshes = EditorGUILayout.Toggle("Replace Scene Meshes", generateMeshReplaceSceneMeshes);
                    else
                    {
                        using (new AmazingAssets.EditorGUIUtility.GUIEnabled(false))
                        {
                            EditorGUILayout.Toggle("Replace Scene Meshes", false);
                        }
                    }
                }
                #endregion


                //Reserve for 
                EditorGUILayout.GetControlRect(GUILayout.Height(50));
            }

            void MeshGeneratorDrawGenerateButton()
            {
                if (generateMeshBatchObjects == null || generateMeshBatchObjects.Count == 0)
                    return;


                using (new AmazingAssets.EditorGUIUtility.GUIEnabled(IsMeshGeneratorReady()))
                {
                    Rect controlRect = EditorGUILayout.GetControlRect();

                    string buttonName = "Generate Wireframe Mesh";
                    if (generateMeshBatchObjectsMeshCount > 1)
                        buttonName = "Generate (" + generateMeshBatchObjectsMeshCount + ") Wireframe Meshes";

                    if (GUI.Button(new Rect(controlRect.xMin + 4, this.position.height - 59 + scroll.y, controlRect.width - 10, 40), buttonName))
                    {

                        float currentIndex = 0;


                        Dictionary<Mesh, Mesh> generatedMeshInfo = new Dictionary<Mesh, Mesh>();


                        foreach (KeyValuePair<string, List<Mesh>> entry in generateMeshBatchObjects)
                        {
                            if (entry.Key == null || entry.Value == null || entry.Value.Count == 0 || entry.Value.Where(a => a!= null).Count() == 0)
                                continue;



                            string saveFolderName = string.Empty;
                            switch (generateMeshSaveLocation)
                            {
                                case SAVE_LOCATION.SameAsSourceAsset:
                                    {
                                        try
                                        {
                                            saveFolderName = Path.GetDirectoryName(entry.Key);
                                        }
                                        catch (Exception)
                                        {
                                            saveFolderName = string.Empty;
                                        }


                                        if (string.IsNullOrEmpty(saveFolderName) || saveFolderName.IndexOf("Assets")!= 0)
                                            saveFolderName = "Assets";
                                            
                                    }
                                    break;

                                case SAVE_LOCATION.SameAsSourceAssetButInSubfolder:
                                    {
                                        try
                                        {
                                            saveFolderName = Path.GetDirectoryName(entry.Key);
                                        }
                                        catch (Exception)
                                        {
                                            saveFolderName = string.Empty;
                                        }


                                        if (string.IsNullOrEmpty(saveFolderName) || saveFolderName.IndexOf("Assets")!= 0)
                                            saveFolderName = "Assets";
                                        

                                        saveFolderName = Path.Combine(saveFolderName, string.IsNullOrEmpty(generateMeshSubfolderName.Trim())? defaultSubFolderName : generateMeshSubfolderName.Trim());

                                        if (Directory.Exists(saveFolderName) == false)
                                            Directory.CreateDirectory(saveFolderName);
                                    }
                                    break;

                                case SAVE_LOCATION.CustomFolder:
                                    {
                                        saveFolderName = generateMeshSaveFolderCustomPath;

                                        if (Directory.Exists(saveFolderName) == false)
                                            Directory.CreateDirectory(saveFolderName);
                                    }
                                    break;
                            }

                            if (generateMeshRootObjectFolder)
                            {
                                string rootAssetName = string.Empty;
                                if (string.IsNullOrEmpty(entry.Key))
                                    rootAssetName = "Unity Built-in Resources";
                                else
                                    rootAssetName = Path.GetFileName(entry.Key).Replace(".", "_");


                                saveFolderName = Path.Combine(saveFolderName, rootAssetName);
                                if (Directory.Exists(saveFolderName) == false)
                                    Directory.CreateDirectory(saveFolderName);
                            }


                            for (int i = 0; i < entry.Value.Count; i++)
                            {
                                if (entry.Value[i] == null)
                                    continue;


                                UnityEditor.EditorUtility.DisplayProgressBar("Hold On", entry.Value[i].name, (currentIndex++) / generateMeshBatchObjectsMeshCount);


                                //Is mesh readable?
                                if (entry.Value[i].isReadable == false)
                                {
                                    ModelImporter modelImporter = AssetImporter.GetAtPath(entry.Key) as ModelImporter;
                                    if (modelImporter!= null)
                                    {
                                        modelImporter.isReadable = true;

                                        AssetDatabase.ImportAsset(entry.Key);

                                        AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);
                                    }
                                }



                                Mesh wireframeMesh = entry.Value[i].GenerateWireframeMesh(generateMeshNormalizeEdges, generateMeshTryQuad);
                                if (wireframeMesh!= null)
                                {
                                    string meshName = entry.Value[i].name;
                                    if (string.IsNullOrEmpty(meshName.Trim()))
                                        meshName = entry.Value[i].GetInstanceID() + "_Wireframe";

                                    string saveAssetName = (string.IsNullOrEmpty(generateMeshFilePrefix.Trim())? string.Empty : generateMeshFilePrefix.Trim()) + meshName + (string.IsNull