Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

How to create a custom package with optional extensions/modules?

Discussion in 'Package Manager' started by Mathijs_Bakker, Dec 4, 2019.

  1. Mathijs_Bakker

    Mathijs_Bakker

    Joined:
    Apr 28, 2014
    Posts:
    25
    We have a tooling package with some optional extensions/modules.

    Like:
    <root>
    ├── package.json
    ├── README.md
    ├── CHANGELOG.md
    ├── LICENSE.md
    ├── Editor
    │ ├── Unity.[YourPackageName].Editor.asmdef
    │ └── EditorExample.cs
    ├── Runtime
    │ ├── Unity.[YourPackageName].asmdef
    │ └── RuntimeExample.cs
    ├── Tests
    │ ├── Editor
    │ │ ├── Unity.[YourPackageName].Editor.Tests.asmdef
    │ │ └── EditorExampleTest.cs
    │ └── Runtime
    ├── Demos // This needs to be optional
    │ ├── Example 1
    │ └── Example 2
    ├── Extensions
    │ ├── Option 1 // This needs to be optional
    │ └── Option 2 // This needs to be optional

    ├── Unity.[YourPackageName].Tests.asmdef
    │ └── RuntimeExampleTest.cs
    └── Documentation~
    └── [YourPackageName].md



    Is there a way to flag a folder as a module? So you the user can be prompted to add that folder for installation. Or do we have to create an extra package - for the particular extension - and add a dependency?

    The same goes for Demos. In the Unite's Copenhagen talk there's an example of using a .sample.jason manifest.

    Are there any best practices to this?
     
    Last edited: Dec 5, 2019
    mitaywalle likes this.
  2. Mathijs_Bakker

    Mathijs_Bakker

    Joined:
    Apr 28, 2014
    Posts:
    25
    Last edited: Dec 5, 2019
  3. M_R

    M_R

    Joined:
    Apr 15, 2015
    Posts:
    558
    separate packages is the cleanest way (you can add a script to the main package that manages the sub-packages and adds them to the project using UPM API)

    that way you can add more extensions without being forced to upgrade the main package
     
    mitaywalle likes this.
  4. Mathijs_Bakker

    Mathijs_Bakker

    Joined:
    Apr 28, 2014
    Posts:
    25
    Thank you for your response,
    Yes I was thinking the same, about the approach you mentioned. Thus separate packages with dependencies to the main package. Or the other way. Will investigate it further.
     
  5. mitaywalle

    mitaywalle

    Joined:
    Jul 1, 2013
    Posts:
    246