I am currently working on my own project and as it’s going forward, I am splitting useful systems to packages for opensourcing.
One problem that I encounter is that once I’ve published a package to git, the only way to test that i did not mess up the packaging or version number update is to add it to the project as git url.
So :
I need to delete the folder i used to develop the module in asset dir (or I will have duplicate classes) …
Add the project as a git url and check if i did not mess up
Now :
I messed up !
I need to remove the package !
Reclone in asset dir …
Make my fix
push to git
delete the cloned package
reimport the dependency as a git package and check again…
It gets even worse when I have to modify the samples since the folders are hidden (when using ~) !
I’m really curious about other people workflows, because this impeds the speed of my development process !
I’d like to be able to have my game and casually edit my plugins then push the new changes easily.
A solution ?
Add a dev option for the packages and when checked, clone (so that i can push changes !!) the package in Assets/ and override the package with the one in Assets/ … When unchecked, just re-use the one in PackageCache …
We don’t currently have that option but I can think of an idea that can help you out to accelerate your workflow.
First, don’t work in the Assets directory. Packages in that folder are not “seen” by the package manager, so if they have dependencies, they won’t be included in your project and installed/loaded into the project by the Package Manager. Instead, you should either use a local dependency (using file:<path-to-package-directory> as the dependency string in the manifest) (read more about local dependencies) or an embedded package (read more about embedded packages).
The simplest is to set up a script that will toggle between a “file:…” dependency and your Git URL. You can use the Package Manager’s C# API for that, for instance by creating a Menu Item that adds your package from disk (using UnityEditor.PackageManager.Client.Add("<path-to-package>")) and another one that adds your package with your Git URL (using UnityEditor.PackageManager.Client.Add("<git URL>"))
Pro tip: to save on pushing and cloning from Github, you can even instruct the Package Manager to pull from your local repository. This can be achieved by using a “git+file://…” URL, as documented in the Unity Manual. For instance, if the package repo was cloned into c:\git-repos\my-package, you could do something like UnityEditor.PackageManager.Client.Add("git+file:///c:/git-repos/my-package#my-branch") (notice the backslashes are switched to forward slashes, to be in the correct order for this to be a valid URL; and there are indeed three slashes after “git+file:”).
I’d simply setup a second project for testing that imitates a user’s project where all packages are imported in the way a user would.
For sure you’d have to have self-contained tests, like each package containing test scenes with which you can verify correct operation along with unit tests.
And yes, all my assets live in the Package Manager side of things, I only have them under Assets when I’m just starting.
I resorted to use a second repo containing git submodules of my packages, then I added them as “package from disk” and developed a little GUI to export and reimport back the demos from and into them (Good thing there the “Sample” class in Package Manager to get the path and do the import into assets)
Since those packages are not read-only I can edit them from my IDE and push the changes (even better, if I forget a meta file, it gets created ! And I’ll still have version control if something gets changed anyway).
My tool can push the demo back into assets, I can modify and test them, then send them back into the repo…
I just need to code some UI to handle the submodule shenanigans and it’ll be good to go…
Anyway that’s too bad, we should not need to go though all this to have a (mostly) painless worfklow
Of course this won’t really fix the “i want to check if package + git is configured correctly” issue" but since it was mostly manifest errors that I had, this should do the trick.
I just published version 0.1.0 of my package to GitHub, created a v0.1.0 tag, and created a (GitHub) release for v0.1.0. Then I bumped the version number in my package to 0.2.0 and clicked on the “Update” button in the Package Manager in Unity, expecting (hoping) to see version 0.1.0 and 0.2.0 in the Version History tab on the package, but I only see 0.2.0…
Yeah I’d like to see some official posts from Unity about this as it’s a pretty fair topic. I have similar questions and currently have a test project that contains the Git repo for my project in a subfolder. Submodules seem like the right way to go but I’m just getting started here and am not an experienced asset dev.