private void OnRemoveDCCToolButtonClicked(EventBase evt) { DCCToolInfo dccToolInfo = GetEventButtonUserDataAs <DCCToolInfo>(evt.target); if (null == dccToolInfo || string.IsNullOrEmpty(dccToolInfo.AppPath)) { Debug.LogWarning("[MeshSync] Failed to remove DCC Tool"); return; } MeshSyncEditorSettings settings = MeshSyncEditorSettings.GetOrCreateSettings(); if (settings.RemoveDCCTool(dccToolInfo.AppPath)) { //Delete install info too string installInfoPath = DCCPluginInstallInfo.GetInstallInfoPath(dccToolInfo); if (File.Exists(installInfoPath)) { DCCPluginInstallInfo installInfo = FileUtility.DeserializeFromJson <DCCPluginInstallInfo>(installInfoPath); installInfo.RemovePluginVersion(dccToolInfo.AppPath); FileUtility.SerializeToJson(installInfo, installInfoPath); } if (!m_dccContainers.TryGetValue(dccToolInfo.AppPath, out VisualElement container)) { SetupInternal(m_root); return; } container.parent.Remove(container); //Remove the VisualElement container from the UI } }
void OnRemoveDCCToolButtonClicked(EventBase evt) { Button button = evt.target as Button; if (null == button) { Debug.LogWarning("[MeshSync] Failed to Remove DCC Tool"); return; } DCCToolInfo info = button.userData as DCCToolInfo; if (null == info || string.IsNullOrEmpty(info.AppPath)) { Debug.LogWarning("[MeshSync] Failed to Remove DCC Tool"); return; } MeshSyncEditorSettings settings = MeshSyncEditorSettings.GetOrCreateSettings(); if (settings.RemoveDCCTool(info.AppPath)) { //Delete install info too string installInfoPath = DCCPluginInstallInfo.GetInstallInfoPath(info); if (File.Exists(installInfoPath)) { File.Delete(installInfoPath); } Setup(m_root); } }
//---------------------------------------------------------------------------------------------------------------------- internal DCCPluginInstallInfo FindInstallInfo() { string path = DCCPluginInstallInfo.GetInstallInfoPath(m_dccToolInfo); if (!File.Exists(path)) return null; return FileUtility.DeserializeFromJson<DCCPluginInstallInfo>(path); }
internal static bool InstallDCCPlugin(BaseDCCIntegrator integrator, DCCToolInfo dccToolInfo, string pluginVersion, string dccPluginLocalPath) { bool dccConfigured = false; //Extract string localPluginPath = dccPluginLocalPath; string tempPath = FileUtil.GetUniqueTempPathInProject(); Directory.CreateDirectory(tempPath); ZipUtility.UncompressFromZip(localPluginPath, null, tempPath); //Go down one folder string[] extractedDirs = Directory.GetDirectories(tempPath); if (extractedDirs.Length > 0) { dccConfigured = integrator.ConfigureDCCToolV(dccToolInfo, extractedDirs[0],tempPath); } //Cleanup FileUtility.DeleteFilesAndFolders(tempPath); if (!dccConfigured) { return false; } string installInfoPath = DCCPluginInstallInfo.GetInstallInfoPath(dccToolInfo); string installInfoFolder = Path.GetDirectoryName(installInfoPath); if (null == installInfoPath || null == installInfoFolder) { integrator.SetLastErrorMessage($"Invalid path: {installInfoPath}"); return false; } //Write DCCPluginInstallInfo for the version Directory.CreateDirectory(installInfoFolder); DCCPluginInstallInfo installInfo = FileUtility.DeserializeFromJson<DCCPluginInstallInfo>(installInfoPath); if (null == installInfo) { installInfo = new DCCPluginInstallInfo(); } installInfo.SetPluginVersion(dccToolInfo.AppPath, pluginVersion); try { FileUtility.SerializeToJson(installInfo, installInfoPath); } catch (Exception e) { integrator.SetLastErrorMessage(e.ToString()); return false; } return true; }
//---------------------------------------------------------------------------------------------------------------------- internal void Integrate(Action onComplete) { string dccToolName = GetDCCToolInFileNameV(); string dccPluginFileName = dccToolName + "_" + GetCurrentDCCPluginPlatform() + ".zip"; //Make sure the DCC plugin zip file exists first DCCPluginDownloader downloader = new DCCPluginDownloader(false,SAVED_PLUGINS_FOLDER, new string[] { dccPluginFileName } ); string dccDesc = m_dccToolInfo.GetDescription(); string progressBarInfo = "Installing plugin for " + dccDesc; EditorUtility.DisplayProgressBar("MeshSync", progressBarInfo,0); downloader.Execute((string pluginVersion, List<string> dccPluginLocalPaths) => { EditorUtility.DisplayProgressBar("MeshSync", progressBarInfo, 0.5f); bool dccConfigured = false; if (dccPluginLocalPaths.Count >0 && File.Exists(dccPluginLocalPaths[0])) { //Extract string localPluginPath = dccPluginLocalPaths[0]; string tempPath = FileUtil.GetUniqueTempPathInProject(); Directory.CreateDirectory(tempPath); ZipUtility.UncompressFromZip(localPluginPath, null, tempPath); dccConfigured = ConfigureDCCToolV(m_dccToolInfo, Path.GetFileNameWithoutExtension(localPluginPath),tempPath); //Cleanup FileUtility.DeleteFilesAndFolders(tempPath); } if (!dccConfigured) { HandleFailedIntegration("Failed in configuring DCC ", dccDesc); return; } string installInfoPath = DCCPluginInstallInfo.GetInstallInfoPath(m_dccToolInfo); string installInfoFolder = Path.GetDirectoryName(installInfoPath); if (null == installInfoPath || null == installInfoFolder) { HandleFailedIntegration($"Invalid path: {installInfoPath}",dccDesc); return; } //Write DCCPluginInstallInfo for the version Directory.CreateDirectory(installInfoFolder); DCCPluginInstallInfo installInfo = FileUtility.DeserializeFromJson<DCCPluginInstallInfo>(installInfoPath); if (null == installInfo) { installInfo = new DCCPluginInstallInfo(); } installInfo.SetPluginVersion(m_dccToolInfo.AppPath, pluginVersion); try { FileUtility.SerializeToJson(installInfo, installInfoPath); } catch (Exception e) { HandleFailedIntegration(e.ToString(), dccDesc); return; } EditorUtility.ClearProgressBar(); FinalizeDCCConfigurationV(); onComplete(); }, () => { Debug.LogError("[MeshSync] Failed to download DCC Plugin for " + dccDesc); EditorUtility.ClearProgressBar(); }); }