Greetings,
I want to host unitypackage files on GitHub so they can be installed via the Package Manage using the Git URL.
If I use a unitypackage it seems to just download the package without extracting it.
If I instead host the extracted files, it puts them under the Packages folder as readonly (e.g. demo scenes can’t be opened because they are readonly).
How can I achieve installing custom packages from GitHub such that they are not readonly (i.e. simulating how assets are installed from the asset store)?
Thanks in advance!
That’s how packages work.
Packages from git url or the Unity registry are stored under Packages and become read-only.
Packages “added from disk” remain where they are and are writable.
To work with packages under source control that you are currently developing, you pull the package repository somewhere onto your system. Then in Package Manager choose “add from disk” and select the package folder to import the package into the project. The same local repository can be added to multiple Unity projects.
When working with a team, you should have a commonly established folder structure like this so projects and packages share the same root directory:
- …/UnityProjects
- …/UnityPackages
You can then manually edit the project manifest.json to make the referenced “from disk” package paths relative to the common root dir rather than absolute path.
An alternative would be to pull the package repository in each project’s /Packages
folder (eg /Packages/com.mydomain.mypackage/..
). Such packages are called “embedded”. With git you could set this up as a submodule or subtree.
Thanks for the reply. As a follow-up question, I’ve decided to bail on my Demo folder and just setup the package as extracted files instead of a unitypackage file. I can import them into a project using the package manager and the Install from Git URL option. It puts the files in the packagecache, in my case I see them in the Unity Editor under Packages\Midnite Oil Software.
I tried writing a test script referencing components in the package and it’s unable to resolve any of the references.
Here’s the GIT url to my package.
Here’s package.json:
{
"name": "com.midniteoilsoftware.core",
"version": "1.0.0",
"displayName": "Midnite Oil Software Core",
"description": "Core components for Midnite Oil Software Unity projects.",
"unity": "6000.0",
"author": {
"name": "Midnite Oil Software L.L.C.",
"url": "https://github.com/Midnite-Oil-Software-L-L-C"
},
"license": "MIT",
"dependencies": {},
"keywords": [
"core",
"midniteoilsoftware"
],
"documentationUrl": "https://github.com/Midnite-Oil-Software-L-L-C/unity_packages",
"samples": []
}
You will have to use one or more Assembly Definitions for your package scripts.
Moreover, you have some scripts in the root but package structure recommends to put these in either Runtime or Editor folders and leave no assets besides package.json and essential docs at the root.
Thanks again, those changes worked like a charm. I am thinking of adding a Demo or Samples folder with a test scene demonstrating the use of the components in the package. The scene would have a dependency not only on the contents of the package but also TextMeshPro (and TMP Essentials and Extras). Is it possible to automatically pull those in?
You need to specify dependencies to other packages in the package.json even if the dependency is only used by a sample.
An alternative would be to make a separate “samples” package that references both TMP and your own package, but PM won’t automatically resolve references to other git url packages.
Thanks!
I do have an optional Samples package (installed from the Samples tab after installing the package) and it does reference TMP. However, it does not automatically install the Essentials and Extras. If I click into one of the controls on the scene it prompts me to install them.
Is there way to have them automatically installed when I install the Samples package?