This Unity editor extension creates script folders (Editor, Runtime, and each Tests) containing assembly definition files (.asmdef).
When opening the context menu and selecting Create > C# Script Folders and Assemblies with Tests , The root folder (e.g., named YourFeature) and below will be created as follows.
Assets
└── YourFeature
├── Scripts
│ ├── Editor
│ │ └── YourFeature.Editor.asmdef
│ └── Runtime
│ └── YourFeature.asmdef
└── Tests
├── Editor
│ └── YourFeature.Editor.Tests.asmdef
└── Runtime
└── YourFeature.Tests.asmdef
Packages
└── your.package.name
└── YourFeature
├── Editor
│ └── YourFeature.Editor.asmdef
├── Runtime
│ └── YourFeature.asmdef
└── Tests
├── Editor
│ └── YourFeature.Editor.Tests.asmdef
└── Runtime
└── YourFeature.Tests.asmdef
Package folder (e.g., named your.package.name) must be created before. Because you can not open the context menu directly under the Packages folder.
After creating folders, move the Editor, Runtime, and Tests folders directly under the your.package.name folder. And remove the YourFeature folder. Then it will be the same as the official package layout.
Packages
└── your.package.name
├── Editor
│ └── YourFeature.Editor.asmdef
├── Runtime
│ └── YourFeature.asmdef
└── Tests
├── Editor
│ └── YourFeature.Editor.Tests.asmdef
└── Runtime
└── YourFeature.Tests.asmdef
Warning
Move folders using JetBrains Rider. Because to update DotSettings files (see below).
"Assembly Definition References" in each asmdef are set as follows.
YourFeature.Editor
has references toYourFeature
YourFeature
has no referencesYourFeature.Tests
has references toYourFeature
YourFeature.Editor.Tests
has references toYourFeature
andYourFeature.Editor
And creating .csproj.DotSettings file for each assembly. This file is set up to make the Namespace does not correspond to file location inspection work as expected in JetBrains Rider. Do not forget to commit .DotSettings files for that project.
Specifically, disabled the Namespace provider for the following folders.
- Scripts
- Scripts/Runtime
- Tests
- Tests/Runtime
This will result in the expected namespace per folder as follows.
- Scripts/Editor: YourFeature.Editor
- Scripts/Runtime: YourFeature
- Tests/Editor: YourFeature.Editor
- Tests/Runtime: YourFeature
Warning
Under Packages namespace resolution works with Unity 2020.2 or later. Because to use the Root Namespace property of asmdef.
See also: Code Inspections in C# | JetBrains Rider Documentation
You can choose from two typical installation methods.
- Open the Package Manager tab in Project Settings window (Editor > Project Settings)
- Click + button under the Scoped Registries and enter the following settings (figure 1.):
- Name:
package.openupm.com
- URL:
https://package.openupm.com
- Scope(s):
com.nowsprinting
- Name:
- Open the Package Manager window (Window > Package Manager) and select My Registries in registries drop-down list (figure 2.)
- Click Install button on the
com.nowsprinting.create-script-folders-with-tests
package
Figure 1. Package Manager tab in Project Settings window.
Figure 2. Select registries drop-down list in Package Manager window.
If you installed openupm-cli, run the command below:
openupm add com.nowsprinting.create-script-folders-with-tests
MIT License
Open an issue or create a pull request.
Be grateful if you could label the pull request as enhancement
, bug
, chore
, and documentation
. See PR Labeler settings for automatically labeling from the branch name.
Add this repository as a submodule to the Packages/ directory in your project.
Run the command below:
git submodule add https://github.com/nowsprinting/create-script-folders-with-tests.git Packages/com.nowsprinting.create-script-folders-with-tests
Run Actions > Create release pull request > Run workflow and merge created pull request. (Or bump version in package.json on default branch)
Then, Will do the release process automatically by Release workflow. And after tagging, OpenUPM retrieves the tag and updates it.
Do NOT manually operation the following operations:
- Create a release tag
- Publish draft releases