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 all folders below it 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
Important
Package folder (e.g., named your.package.name) and package.json 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:
graph RL
Runtime
Editor --> Runtime
Runtime.Tests --> Runtime
Editor.Tests --> Runtime
Editor.Tests --> Editor
Editor.Tests --> Runtime.Tests
Creates an AssemblyInfo.cs file for each assembly to mark Assembly Definition References as Friend assemblies.
This allows access to internal
types and members.
Creates .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.
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
Tip
Tests
is not included in the namespace.
When the same namespaces as the production code and test code are used, using
directives are not required.
Specifically, disabled the Namespace provider for the following folders:
- Scripts
- Scripts/Runtime
- Tests
- Tests/Runtime
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
- Open the Project Settings window (Editor > Project Settings) and select Package Manager tab (figure 1.)
- Click + button under the Scoped Registries and enter the following settings:
- 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 tab (figure 2.)
- Select Create Script Folders and Assemblies with Tests and click the Install button
Figure 1. Scoped Registries setting in Project Settings window
Figure 2. My Registries in Package Manager window
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 [email protected]:nowsprinting/create-script-folders-with-tests.git Packages/com.nowsprinting.create-script-folders-with-tests
Generate a temporary project and run tests on each Unity version from the command line.
make create_project
UNITY_VERSION=2019.4.40f1 make -k test
The release process is as follows:
- Run Actions > Create release pull request > Run workflow
- Merge created pull request
Then, will do the release process automatically by Release workflow. After tagging, OpenUPM retrieves the tag and updates it.
Caution
Do NOT manually operation the following operations:
- Create a release tag
- Publish draft releases
Caution
You must modify the package name to publish a forked package.