When I reference a package in multiple Unity projects on my machine, will the code for that package be compiled in every project and cached in the respective library folders or is there a shared compilation cache for all projects?
I assume, once a package has been compiled once, it doesn’t have to be recompiled unless updated, at least within the same project, right?
Each project normally has its own copy of packages, and each compiles its own assemblies from the package. This allows different projects to use different Editor versions or target different platforms.
Caveat: This is not entirely true for packages already present locally that you add to a project using the “file:” format, which is intended for development and testing. This kind of dependency will directly load the package assets into the project’s Asset Database, but each project still gets to compile its own set of assemblies. The fact that the package assets are shared may be problematic if you’re referencing the package in projects using different Editor versions because some of its assets may be serialized in incompatible ways for older Editors. This generally won’t be a problem for code-only packages, but those that also include non-code assets may not work properly on older Editors after being opened or edited in newer Editors.