Search Unity

How to add custom default packages to Package Manager!

Discussion in 'Package Manager' started by luvcraft, Dec 17, 2019.

  1. luvcraft

    luvcraft

    Joined:
    Aug 22, 2011
    Posts:
    25
    Every time I make a new project, I have to edit the Package Manager manifest to remove a bunch of things (ads, analytics, etc.), and add my own handy extension method toolbox.

    Via this thread:
    https://forum.unity.com/threads/default-packages.530043/
    ...I learned how to remove default packages I don't want by editing the
    manifest.json
    at
    C:\Program Files\Unity\Hub\Editor\2019.3.0f3\Editor\Data\Resources\PackageManager\Editor
    (or whatever the path to the current editor might be). I also figured out that you can add your own custom packages by adding them to the "defaultDependencies" section.

    However, there's a weird catch; custom packages use the format
    "packagename": "package git URL"
    rather than the
    "packagename": "version"
    format that built-in packages use. When you create a new Unity project, Unity cares about this formatting, and complains that there's a package with the wrong format, and creates your project with an empty Packages/manifest.json. However, if you delete that empty manifest.json and let Unity recreate it, it won't do that formatting check, and will happily create exactly the manifest file you want. Likewise, if you have any other existing Unity project and want to apply these new default packages, you can just delete the existing manifest and let Unity recreate it and it will be happy.

    Hopefully someone on the Package Manager team will see this post and throw out that extraneous formatting check on new project creation, or suggest a better method for doing this. :)
     
    BTStone likes this.
  2. maximeb_unity

    maximeb_unity

    Unity Technologies

    Joined:
    Mar 20, 2018
    Posts:
    161
    Hi @luvcraft,

    We don't plan on removing this check. That file is not meant as a way to customize new projects. That said, congrats on finding that :)

    However I'm not going to let you down - I have -probably- better solution for you.

    If you don't mind using the command-line when creating a new project, you can create your own private templates, and control how Unity creates your projects. You'll need to use the following arguments together (note: some of those are internal/undocumented, and may change in the future, but at least they'll save you from altering your local Editor installations).
    • -createProject <absolute-path-to-new-project>
      : this tells Unity to create a new project at that location
    • -cloneFromTemplate <absolute-path-to-new-project-directory>
      : (internal) this tells Unity to use the referenced template when creating the project. The path must be an absolute path, and the template is expected to be a regular Unity project but without the
      ProjectSettings/ProjectVersion.txt
      file.
    • -upmNoDefaultPackages
      : (internal) this tells Unity to skip the "default packages" step when creating your project.
    Again, just to be 100% clear, please note that both
    -cloneFromTemplate
    and
    -upmNoDefaultPackages
    are internal functionalities and are subject to change in the future (2020.X or later), but they should be perfectly usable in 2019.3 and the upcoming 2019 LTS for the usage you have described. Enjoy!
     
    vestigial likes this.
  3. AccentDave

    AccentDave

    Joined:
    Nov 16, 2015
    Posts:
    38
    My dream: Open Hub, go to Preferences, Custom Templates, and find 'drag your project here' which will install my custom templates. And, such that I don't have to tgz them myself (can we please use zip, or just un-archived like 2018.x had?)
     
unityunity