Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: Tricky_Widget on January 02, 2016, 10:21:29 AM

Title: How to access HutongGames.PlayMakerEditor.VersionInfo?
Post 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!
Title: Re: How to access HutongGames.PlayMakerEditor.VersionInfo?
Post by: Tricky_Widget on January 07, 2016, 08:00:25 AM
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?

Code: [Select]
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;
}