Is it possible to pack packages without embedding them?

Hey, recently I was trying to use package manager, for my next project. Normally I packed the package as embedded system. It’s very useful that I can setup package version, upload it to another projects via package manager. However I decided to not embedded the package since I want to modify the content in other projects.

Btw if I understand correctly, embedded packages goes into Packages folder instead Assets folder.

So is there any way, continue using package manager to handle my package without embedding the package. (when I install package in another project, I need it to import inside of the Assets folder)

9785058--1403781--upload_2024-4-22_3-28-58.png

Yes, Packages located in the project‘s Packages folder are called „embedded“ packages.
Packages located in the Assets tree are not technically packages but merely „assets“.

The correct way to develop AND share packages is to create a package in a folder outside of any project, eg in a folder sibling (next to) a project. Then this package must be „imported from disk“ to preserve its location and writable status.

Naturally you will have either separate repositories for your packages (recommended) or a combined repository where both package(s) and project(s) are located in subfolders.

1 Like

Embedding is a valid package development strategy, shareable with git URL using path query option
https://github.com/Unity-Technologies/InputSystem/tree/develop/Packages

Avoid putting packages in Assets, there will be path-based operations that will behave incorrectly (Gizmos, UITK references, shader includes)

1 Like

I believe I understand, so just to clarify, I created a package outside of the Unity, and give it a package.json file. Whenever I want to modify the content of this project I needs to work inside this folder, independent from Unity project.

The procedures I followed:

  1. Create any folder outside of Unity project.
  2. Put my project files (example some c# script)
  3. Create package.json file.
  4. Open package manager and add package from disk.
  5. Import. Here still package automatically placed inside the Packages folder.

9786039--1404036--upload_2024-4-22_15-46-8.png

9786039--1404042--upload_2024-4-22_15-46-23.png

If I understand you both correctly, this is normal because I need to continue developing packages independently. However is there a way, that very similar to download assets from asset store? Because it also use package manager, has updates via package manager etc., but when download package from asset store, it place the asset inside the Assets folder (if not selected as embedded). Because I’m working on a horror game + horror game engine, creating a package for the horror game engine and importing it inside the horror game works great. But since it embed the package, when I want to modify some prefab, I need to duplicate the asset, and create one copy of it inside assets folder since all package located under Packages folder.

(Edit)
Btw I was also thinking about git submodules for such need. Maybe it’s a better idea? Or it’s just better idea if I want to continue developing the package in both projects?

Hi @yanard18 ,

Asset Store packages use a different package mechanism, which largely predates the Package Manager. It’s a bit confusing because they’re also called packages, but often they are referred as asset packages (whose contents is exported from Assets and imported into Assets) rather than UPM packages (whose contents is loaded separately from the Assets folder, which provides better encapsulation, scalability and upgradability). The Package Manager is not a general interface for asset packages, just for the Asset Store. You can still export asset packages (.unitypackage files) from your Assets directory, then that package can be imported in any other project’s Assets directory by using the Assets -> Import Package menu item.

What you’re asking for requires you to write some scripts that will automate the task you want. You could look into using Samples as a mechanism for this, even though they’re not really samples, or implement your own mechanism that copies the assets you wish to be present in the Assets directory from your package. There’s a few gotchas to the latter, though, so I suggest you look at Samples first.

Small clarification: when you use the “Add package from disk”, it does not actually copy the UPM package into your project’s Packages directory, but instead Unity provides a virtual view of the package as if it was there. An embedded package, on the other hand, is physically present at that location, rather than virtually presented there and loaded via a configured dependency.

2 Likes

Hey @maximeb_unity ,

Thanks for clarification, now it’s all clear for me. Also this Sample mechanism very useful which I didn’t know exist.

1 Like

If this prefab is provided by the Asset Store “asset package” then it’s generally advisable to make duplicates of these assets whenever feasible. Otherwise the next time the publisher publishes an update with modifications to that exact prefab you may lose your edits when you import that asset update.

No. You have the package imported into the project, so it will be accessible from within the Project view and the IDE.