-
-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
documentationImprovements or additions to documentationImprovements or additions to documentationenhancementNew feature or requestNew feature or request
Description
Description
Currently, the createProject function in UnityEditor allows creating new Unity projects programmatically, but it doesn't support creating projects from templates like the "URP template" or other built-in and custom templates. Unity has an undocumented feature to create projects from templates that would be valuable to expose through this library.
Proposed Solution
Enhance the createProject function to add support for template-based project creation by:
- Adding a new optional parameter
templateto thecreateProjectfunction - Implementing the logic to detect available templates (both built-in and custom)
- Supporting creation from these templates via command-line arguments
Technical Details
Unity implements templates as packages in specific locations:
- Built-in templates are stored in
[Unity Editor Path]/Editor/Data/Resources/PackageManager/ProjectTemplateson Windows - On macOS, they're in
/Applications/Unity/Hub/Editor/[VERSION]/Unity.app/Contents/Resources/PackageManager/ProjectTemplates - Custom templates can be created and placed in these directories
When a template is selected in Unity Hub, it reads the template package (usually a .tgz file), extracts it, and uses its content as a base for the new project. This includes package dependencies, initial assets, and project settings.
Implementation approach
- Add a way to list available templates (through a new method like
getAvailableTemplates()) - Enhance
createProjectto accept template name/path as an optional parameter - Implement the command-line command that uses the undocumented template feature
Example Usage
// Create a project using the URP template
const projectInfo: ProjectInfo = {
projectPath: "/path/to/new/project",
editorVersion: "2022.3.15f1",
template: "com.unity.template.universal" // or "URP" as a friendly name
};
await UnityEditor.createProject(projectInfo);
// Alternatively, list available templates first
const templates = await UnityEditor.getAvailableTemplates("2022.3.15f1");
console.log(templates); // Would return something like { "URP": "com.unity.template.universal", ... }Metadata
Metadata
Assignees
Labels
documentationImprovements or additions to documentationImprovements or additions to documentationenhancementNew feature or requestNew feature or request