#Detect if a package is installed

1 messages · Page 1 of 1 (latest)

viral tree
#

Hey, I've been trying to figure out how to properly detect whether a package is in the project.
There are a few solutions I've seen, for example, this one is very clean: https://discussions.unity.com/t/detect-if-a-package-is-installed/838614/13
However, it has a major flaw.
If the asset is not a regular package, but .unitypackage you manually import, for example Steam Audio, this isn't doable from what I can tell: https://github.com/ValveSoftware/steam-audio/blob/master/unity/doc/getting-started.rst
Picture 1 clearly shows that there is nothing containing steam in the name.
Now, of course I could use #if STEAMAUDIO_ENABLED as shown in their docs, but there is yet another issue.
Last time I asked about this, I was told that there is no way to unregister the scripting define symbol when a package is uninstalled, the user has to do it manually.
I hope you can see how this is error prone.
Say somebody uses steam audio, decides to drop it, then installs my package which optionally uses steam audio, we end up with a really weird issue.
So yeah, I am just hoping somebody has a good solution to this problem, a reliable way to check whether a package(of any kind, be it git, unity package, openupm) is installed.
Please @ me and thanks in advance!

scenic fjord
#

A .unitypackage is not a package and only consists of whatever assets were imported into the project. It's just a fancy zip

viral tree
fluid pine
#

You could do reflection and see if a given class in it exists, but that's pretty fragile.

scenic fjord
#

and it won't work if the case you're trying to solve against causes errors in the first place