void OnInstallPluginButtonClicked(EventBase evt) { if (null == m_latestCompatibleDCCPluginVersion) { EditorUtility.DisplayDialog("MeshSync", $"DCC Plugin compatible with MeshSync@{MeshSyncEditorConstants.GetPluginVersion()} is not found", "Ok" ); return; } BaseDCCIntegrator integrator = GetEventButtonUserDataAs <BaseDCCIntegrator>(evt.target); if (null == integrator) { Debug.LogWarning("[MeshSync] Failed to Install Plugin"); return; } integrator.Integrate(m_latestCompatibleDCCPluginVersion.ToString(), () => { DCCToolInfo dccToolInfo = integrator.GetDCCToolInfo(); if (!m_dccStatusLabels.TryGetValue(dccToolInfo.AppPath, out Label statusLabel)) { SetupInternal(m_root); return; } UpdateDCCPluginStatusLabel(statusLabel); }); }
//---------------------------------------------------------------------------------------------------------------------- void UpdateDCCPluginStatusLabel(Label statusLabel) { BaseDCCIntegrator dccIntegrator = statusLabel.userData as BaseDCCIntegrator; Assert.IsNotNull(dccIntegrator); DCCPluginInstallInfo installInfo = dccIntegrator.FindInstallInfo(); const string NOT_INSTALLED = "MeshSync Plugin not installed"; if (null == installInfo) { statusLabel.text = NOT_INSTALLED; return; } DCCToolInfo dccToolInfo = dccIntegrator.GetDCCToolInfo(); string installedPluginVersionStr = installInfo.GetPluginVersion(dccToolInfo.AppPath); if (string.IsNullOrEmpty(installedPluginVersionStr)) { statusLabel.text = NOT_INSTALLED; return; } //Remove all known classes const string PLUGIN_INCOMPATIBLE_CLASS = "plugin-incompatible"; const string PLUGIN_INSTALLED_OLD_CLASS = "plugin-installed-old"; const string PLUGIN_INSTALLED_CLASS = "plugin-installed"; statusLabel.RemoveFromClassList(PLUGIN_INCOMPATIBLE_CLASS); statusLabel.RemoveFromClassList(PLUGIN_INSTALLED_CLASS); statusLabel.RemoveFromClassList(PLUGIN_INSTALLED_OLD_CLASS); PackageVersion pluginVer = MeshSyncEditorConstants.GetPluginVersion(); //The DCC Plugin is installed, and we need to check if it's compatible with this version of MeshSync if (!IsPackageVersionCompatible(installedPluginVersionStr, pluginVer, out PackageVersion installedPluginVersion)) { statusLabel.AddToClassList(PLUGIN_INCOMPATIBLE_CLASS); statusLabel.text = "Installed MeshSync Plugin is incompatible. Version: " + installedPluginVersionStr; return; } //Check if we have newer compatible DCCPlugin if (null != m_latestCompatibleDCCPluginVersion && installedPluginVersion.GetPatch() < m_latestCompatibleDCCPluginVersion.GetPatch()) { statusLabel.AddToClassList(PLUGIN_INSTALLED_OLD_CLASS); statusLabel.text = $"Plugin {installedPluginVersionStr} installed. " + $"({m_latestCompatibleDCCPluginVersion} is available)"; return; } statusLabel.AddToClassList(PLUGIN_INSTALLED_CLASS); statusLabel.text = $"Plugin {installedPluginVersionStr} installed"; }
void UpdateLatestCompatibleDCCPlugin(VersionsInfo versionsInfo) { PackageVersion pluginVer = MeshSyncEditorConstants.GetPluginVersion(); foreach (string dccPluginVerStr in versionsInfo.all) { //Skip incompatible versions if (!IsPackageVersionCompatible(dccPluginVerStr, pluginVer, out PackageVersion dccPluginVer)) { continue; } if (null == m_latestCompatibleDCCPluginVersion || dccPluginVer.GetPatch() > m_latestCompatibleDCCPluginVersion.GetPatch()) { m_latestCompatibleDCCPluginVersion = dccPluginVer; } } }
void UpdateLatestCompatibleDCCPlugin(VersionsInfo versionsInfo) { PackageVersion pluginVer = MeshSyncEditorConstants.GetPluginVersion(); foreach (string dccPluginVer in versionsInfo.all) { bool parsed = PackageVersion.TryParse(dccPluginVer, out PackageVersion dccPluginPackageVersion); Assert.IsTrue(parsed); //Skip incompatible versions if (dccPluginPackageVersion.GetMajor() != pluginVer.GetMajor() || dccPluginPackageVersion.GetMinor() != pluginVer.GetMinor()) { continue; } if (null == m_latestCompatibleDCCPluginVersion || dccPluginPackageVersion.GetPatch() > m_latestCompatibleDCCPluginVersion.GetPatch()) { m_latestCompatibleDCCPluginVersion = dccPluginPackageVersion; } } }