Esempio n. 1
0
        private static bool GetIntegrationFolder(DCCIntegration dcc)
        {
            // decompress zip file if it exists, otherwise try using default location
            var zipPath = dcc.IntegrationZipFullPath;

            if (System.IO.File.Exists(zipPath))
            {
                return(DecompressIntegrationZipFile(zipPath, dcc));
            }
            dcc.SetIntegrationFolderPath(ExportSettings.IntegrationSavePath);
            return(true);
        }
Esempio n. 2
0
        private static bool DecompressIntegrationZipFile(string zipPath, DCCIntegration dcc)
        {
            // prompt user to enter location to unzip file
            var unzipFolder = EditorUtility.OpenFolderPanel(string.Format("Select Location to Save {0} Integration", dcc.DccDisplayName), ExportSettings.IntegrationSavePath, "");

            if (string.IsNullOrEmpty(unzipFolder))
            {
                // user has cancelled, do nothing
                return(false);
            }

            ExportSettings.IntegrationSavePath = unzipFolder;

            // check that this is a valid location to unzip the file
            if (!DirectoryHasWritePermission(unzipFolder))
            {
                // display dialog to try again or cancel
                var result = UnityEditor.EditorUtility.DisplayDialog("No Write Permission",
                                                                     string.Format("Directory \"{0}\" does not have write access", unzipFolder),
                                                                     "Select another Directory",
                                                                     "Cancel"
                                                                     );

                if (result)
                {
                    InstallDCCIntegration();
                }
                else
                {
                    return(false);
                }
            }

            // if file already unzipped in this location, then prompt user
            // if they would like to continue unzipping or use what is there
            if (dcc.FolderAlreadyUnzippedAtPath(unzipFolder))
            {
                var result = UnityEditor.EditorUtility.DisplayDialogComplex("Integrations Exist at Path",
                                                                            string.Format("Directory \"{0}\" already contains the decompressed integration", unzipFolder),
                                                                            "Overwrite",
                                                                            "Use Existing",
                                                                            "Cancel"
                                                                            );

                if (result == 0)
                {
                    DecompressZip(zipPath, unzipFolder);
                }
                else if (result == 2)
                {
                    return(false);
                }
            }
            else
            {
                // unzip Integration folder
                DecompressZip(zipPath, unzipFolder);
            }

            dcc.SetIntegrationFolderPath(unzipFolder);

            return(true);
        }