Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: Tricky_Widget on January 02, 2016, 10:21:29 AM
-
I have an asset that needs to handle the differences between PlayMaker 1.7 and 1.8. So I need to check the PM version in code. I see that there is a HutongGames.PlayMakerEditor.VersionInfo, but I can't figure out how to access it. Can anyone help?
Thanks!
-
OK, I condensed this out of PlayMakerWelcomeWindow.cs, which checks the version. It works, but it seems absurdly complicated. Does anyone know if there's a better way to do this?
private static int GetPlayMakerVersion()
{
Type versionInfo = null;
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
{
versionInfo = assembly.GetType("HutongGames.PlayMakerEditor.VersionInfo");
if (versionInfo != null)
break;
}
if (versionInfo != null)
{
var currentVersion = (string)versionInfo.GetMethod("GetAssemblyInformationalVersion").Invoke(null, null);
if (currentVersion != null)
return int.Parse(currentVersion.Substring(0, currentVersion.LastIndexOf('.')).Substring(0, 3).Replace(".", ""));
else
return -1;
}
else
return -1;
}