static void MeshSyncEditorConstants_OnLoad() { bool parsed = PackageVersion.TryParse(Lib.GetPluginVersion(), out m_pluginVersion); Assert.IsTrue(parsed); }
//---------------------------------------------------------------------------------------------------------------------- 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(); //[TODO-sin: 2021-10-28] this TryParse() check is called more than once in this file. Refactor this code //The DCC Plugin is installed, and we need to check if it's compatible with this version of MeshSync bool parsed = PackageVersion.TryParse(installedPluginVersionStr, out PackageVersion installedPluginVersion); if (!parsed || installedPluginVersion.GetMajor() != pluginVer.GetMajor() || installedPluginVersion.GetMinor() != pluginVer.GetMinor()) { 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"; }