Search Unity

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:
    18
    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
  2. Mathijs_Bakker

    Mathijs_Bakker

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

    M_R

    Joined:
    Apr 15, 2015
    Posts:
    528
    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
     
  4. Mathijs_Bakker

    Mathijs_Bakker

    Joined:
    Apr 28, 2014
    Posts:
    18
    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.