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

We have a tooling package with some optional extensions/modules.

Like:

├── 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?

1 Like

For demos there’s this approach: Samples in Packages - Manual Setup

Is there something available for modules/extensions too?

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

1 Like

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.

If optional module has a another package as dependency we can use AssemblyDefenition.VersionDefines for this Unity - Manual: Assembly definitions