Skip to content

needle-tools/needle-engine-typescript-codegen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Needle Engine C# → TypeScript Codegen

Unity Editor package that converts C# components to TypeScript starter code for Needle Engine — a web-based 3D engine that brings Unity workflows to the browser using three.js under the hood.

This is not a full automatic conversion — it generates a starting point for porting existing C# Unity projects to Needle Engine.

Learn more about Needle Engine at needle.tools or check the documentation.

Features

  • Converts C# classes, structs, and enums to TypeScript
  • Maps Unity types to Needle Engine equivalents (e.g. Vector3, Transform, Animator)
  • Generates fields, properties, and method stubs
  • Supports nullable types, field initializers, delegates, generics, and abstract classes
  • Preserves XML doc comments and @serializeable() decorators
  • Handles HideInInspector via @nonSerialized() attribute

Requirements

Installation

Install via Needle Installer or add manually via Unity Package Manager using the package name and registry:

com.needle.csharp-to-typescript

Registry: https://packages.needle.tools

Usage

  1. Right-click a C# script in the Unity Project window
  2. Select the conversion option from the context menu
  3. Review and adjust the generated TypeScript

Development

Running Tests

dotnet restore tests/Needle.Engine.TypescriptCodegen.Tests.csproj
dotnet build tests/Needle.Engine.TypescriptCodegen.Tests.csproj --no-restore
dotnet test tests/Needle.Engine.TypescriptCodegen.Tests.csproj --no-build

Publishing

Push to the release/package branch. The CI pipeline runs tests first, then publishes to the package registry.

Project Structure

package/          Unity package (Editor scripts + codegen logic)
  Editor/
    CodeBuilder/  Builders for classes, fields, methods, enums
    CodeWriter/   Code output writers
    Utils/        Type mapping and string utilities
tests/            C# unit tests
projects/         Sample Unity projects

About

Unity Editor package that converts C# components to TypeScript starter code for Needle Engine

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors