Is there a compiler define for imported packages? For example, if i import the Addressables package, is there something like this I can do? Code (csharp): #if PACKAGE_ADDRESSABLES // do all kinds of crazy, wacky addressable stuff here, that would create 8,000 compiler // errors if the addressables package wasn't imported. #endif Because if not, that would be absolutely fantastic.
Look at the Version Defines settings on Assembly Defintions: https://docs.unity3d.com/Manual/ScriptCompilationAssemblyDefinitionFiles.html There you can create defines for your package, based on wether specific versions of other packages are present. The system works a bit differently, there are no global defines, instead you create defines that are local to your package.
Adding my vote to this. Writing a third-party plugin, with integrations into various engine features (like Timeline), would be a lot easier if I could have a define for the presence of the TImeline package. Unfortunately, what Adrian suggested will not work, because my code lives outside of the Timeline package.
The version defines feature does not require changes in the source package (Timeline in your example). It was created to fulfill the exact requirement you are asking for. We decided to go that way because we could not provide *symbols* for all packages plus their specific version. It would generate tons of symbols (maybe megabytes of) in builds that would be mostly unused. We know the feature is less intuitive than having static define. But it returns, it is much more powerful and efficient. Hope it helps, Pascal
As mentioned previouslym this could be implemented through version defines: https://docs.unity3d.com/Manual/class-AssemblyDefinitionImporter.html#version-defines Static define as requested here is not possible, and as explained by Pascal, it will cause a define explosion that is not desirable. Moving forward, it is our scripting team at Unity who are working on things like this and it's out of the Package Managers team. For those here invested in this, would you like me to move the thread to their subforum, or would you like to raise this yourselves in a new thread?
I honestly don't see how this helps us asset creators who rely on other peoples packages, but sure, feel free to move it.