# How to check version of Unity package in project through script

I'm writing an asset that will be used by many people, but it depends on TextMeshPro (TMP). I ran into a bug in TMP that can only be fixed by upgrading to a preview version. I want to warn users that install my asset that they need to upgrade their TMP version if they are using a prior version. Surprisingly, I can't find this anywhere online or in the docs.

just something like

if (TextMeshPro.version < MyAsset.RequiredTMPVersion) {
}


First you search for the package you need info of (TMP) with PackageManager.Client (I think it will look something like this: var tmp = Client.Search("com.unity.textmeshpro").Result;, be aware that .Result is synchronous, maybe there's a better way to implement this using Tasks).
Then you get the package's info (version) with PackageManager.PackageInfo (something like tmp.version). Done.
• The second line needed to be tmp[0].version since the Result is an array. Thanks! – Adam B Mar 25 at 21:10
• Actually I jumped the gun. The result is null. PackageInfo[] textmeshpro = Client.Search("com.unity.textmeshpro").Result; – Adam B Mar 25 at 21:17
• The result is coming as null? Maybe it's due to the .Result, I didn't see it being used that way in documentation, try an async approach, it might work. – Diego Penha Mar 26 at 12:34