playMaker

Author Topic: How to access HutongGames.PlayMakerEditor.VersionInfo?  (Read 1561 times)

Tricky_Widget

  • Junior Playmaker
  • **
  • Posts: 62
How to access HutongGames.PlayMakerEditor.VersionInfo?
« 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!

Tricky_Widget

  • Junior Playmaker
  • **
  • Posts: 62
Re: How to access HutongGames.PlayMakerEditor.VersionInfo?
« Reply #1 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;
}
« Last Edit: January 07, 2016, 08:02:11 AM by Tricky_Widget »