A powerful Unity Editor tool for managing and refactoring C# namespaces based on folder structure. Automatically suggests namespaces, updates using statements, and cleans up unused references.
- 🔍 Folder-based namespace suggestions - Automatically generates namespace based on folder structure
- 🏷️ Customizable prefix - Add your project's root namespace as prefix (e.g.,
MyProject.Core.Utils) - 📦 Batch processing - Select multiple scripts and apply changes at once
- 👀 Affected files preview - See which files will be modified before applying changes
- 🔗 Smart reference updates - Updates
usingstatements and fully-qualified references - 🎯 Type-aware detection - Only updates files that actually use the types being moved
- 🧹 Unused using cleanup - Removes
usingstatements that are no longer needed - 🚫 Duplicate removal - Automatically removes duplicate
usingstatements ⚠️ Conflict detection - Warns when namespace segment matches a type name- 🔎 Filters - Filter by "needs change", "no namespace", or search by name
- Open Package Manager in Unity (
Window > Package Manager) - Click the
+button and selectAdd package from git URL... - Enter the following URL:
https://github.com/xavierarpa/NamespacePath.git- Download or clone the repository
- Copy the
namespacePathfolder into your project'sAssets/Plugins/folder
Go to Tools > Namespace Path in the Unity menu bar.
- Set Source Folder - Drag a folder from your Project window to the "Source Folder" field
- Set Namespace Prefix - Enter your project's root namespace (e.g.,
MyProject) - Click "Scan Scripts" - The tool will analyze all C# files in the folder
- Review suggestions - Each script shows its current namespace and suggested namespace
- Select scripts - Check the scripts you want to modify
- Preview affected files - Click "View Affected" to see what files will be updated
- Apply changes - Click "Apply Changes" to execute the refactoring
| Option | Description |
|---|---|
| Source Folder | Folder containing the scripts to analyze |
| References Folder | Folder to search for using references (defaults to Assets/) |
| Namespace Prefix | Prefix added to all suggested namespaces |
| Use Source as Root | If enabled, namespace starts from source folder name |
Given this folder structure:
Assets/Scripts/Runtime/Core/
├── Utils/
│ └── Utils.cs (namespace: MyProject.Core)
├── Services/
│ └── GameService.cs (namespace: MyProject.Core)
└── Data/
└── PlayerData.cs (namespace: MyProject.Core)
With Source Folder = Core and Prefix = MyProject:
| File | Current | Suggested |
|---|---|---|
| Utils.cs | MyProject.Core | MyProject.Core.Utils |
| GameService.cs | MyProject.Core | MyProject.Core.Services |
| PlayerData.cs | MyProject.Core | MyProject.Core.Data |
The tool warns you when a namespace segment matches a type name in the same file. For example:
// ⚠️ Warning: namespace ends with 'Utils' which matches the class name
namespace MyProject.Core.Utils
{
public class Utils { } // This causes CS0101 error
}- Scans all
.csfiles in the source folder - Extracts current namespace and type names (classes, structs, interfaces, enums)
- Generates suggested namespace based on folder path
- Detects which files use the types being moved
- Updates the namespace declaration in source files
- Adds new
usingstatements where needed - Cleans up unused
usingstatements
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please read CONTRIBUTING.md for details.
- Author: Xavier Arpa (@xavierarpa)
- Issues: GitHub Issues