I develop a free package, which I distribute through GitHub (so anyone who wants to use it can use the GitHub URL to add it to their project), and for a long time I was struggling with how to set things up so that I can easily make changes to my package. Because if I add my package to a test project I get a copy (so my edits get lost) unless I add the package by absolute path but then I still can’t edit my Samples, and I also can’t move my project from machine to machine.
I now have the following setup, I’m wondering whether this is (1) stupid, (2) smart or (3) what pretty much everyone does. Comments welcome.
I have two repos: MyPackage and MyPackageTest. MyPackage is the one I distribute and MyPackageTest is essentially an empty project with two symlinks in specific places:
MyPackageTest/Packages/MyPackage symlink to ../../MyPackage
MyPackageTest/Assets/Samples/MyPackage/Current symlink to ../../../../MyPackage/Samples~
With this setup I can open the C# scripts in Visual Studio, modify the prefabs and scenes in the samples, anything, and the edits will go to the correct place.
The only gotcha is that you have to ensure that git symlink support is enabled if you’re developing on windows, by doing git config core.symlinks true
@CodeSmile I haven’t found a way to be able to edit the samples if I use “Add from Disk”. I used to continually rename Samples to Samples~ and back (depending on whether I was editing the package or not) but even that created problems because Unity kept complaining that there were scripts outside the Assets directory and this was bad.
Another option is to just add it to Packages as a git submodule.
And another option, though probably not in your case, is to make the GitHub project a proper Unity project with the package embedded in Packages/. These still works with consuming just the package alone from packman. The input system GitHub repo does that, for example.
Ah yeah the “~Samples” problem. Ran into that one before, had no other obvious solution other than renaming it or making a separate package with just the samples in a “Samples” directory but using a symlink or submodule/subtree to embed that content.