Top Related Projects
A framework for building native Windows apps with React.
A framework for building native applications using React
Cocos simplifies game creation and distribution with Cocos Creator, a free, open-source, cross-platform game engine. Empowering millions of developers to create high-performance, engaging 2D/3D games and instant web entertainment.
Godot Engine – Multi-platform 2D and 3D game engine
Kotlin/Native infrastructure
Quick Overview
Puerts is a cross-platform JavaScript/TypeScript integration solution that allows developers to use JavaScript/TypeScript in C++ and C# projects. It provides a seamless way to bridge the gap between native and scripting languages, enabling developers to leverage the strengths of both.
Pros
- Cross-platform Compatibility: Puerts supports multiple platforms, including Windows, macOS, and Linux, making it a versatile choice for developers working on diverse projects.
- TypeScript Support: Puerts fully supports TypeScript, allowing developers to leverage the benefits of static typing and improved tooling.
- Performance Optimization: Puerts is designed for performance, with features like asynchronous function calls and efficient memory management.
- Extensive Documentation: The project has comprehensive documentation, including tutorials, API references, and examples, making it easier for developers to get started and integrate Puerts into their projects.
Cons
- Learning Curve: Integrating Puerts into an existing project may require a significant learning curve, especially for developers unfamiliar with the concept of bridging native and scripting languages.
- Dependency on Specific Frameworks: Puerts is primarily designed to work with Unity and Unreal Engine, which may limit its applicability for developers working with other game engines or native applications.
- Limited Community: Compared to more established JavaScript/TypeScript frameworks, the Puerts community is relatively small, which could make it harder to find support and resources.
- Potential Performance Overhead: While Puerts is designed for performance, there may be some overhead associated with the language bridging, which could be a concern for highly performance-critical applications.
Code Examples
Example 1: Calling a C++ Function from TypeScript
import * as csharp from 'csharp';
// Call a C++ function
const result = csharp.Puerts.TestClass.Add(1, 2);
console.log(result); // Output: 3
This example demonstrates how to call a C++ function from TypeScript using the csharp
module provided by Puerts.
Example 2: Exposing a TypeScript Class to C++
import * as csharp from 'csharp';
class MyClass extends csharp.Puerts.TestClass {
public Add(a: number, b: number): number {
return a + b;
}
}
// Register the TypeScript class with C++
csharp.Puerts.TestClass.Register(MyClass);
This example shows how to expose a TypeScript class to C++ by extending a C++ class and registering the TypeScript class with Puerts.
Example 3: Asynchronous Function Calls
import * as csharp from 'csharp';
async function callAsyncCppFunction() {
const result = await csharp.Puerts.TestClass.DoSomethingAsync();
console.log(result);
}
callAsyncCppFunction();
This example demonstrates how to call an asynchronous C++ function from TypeScript using the await
keyword.
Getting Started
To get started with Puerts, follow these steps:
-
Install the Puerts package in your project:
- For Unity, you can install the package from the Unity Package Manager.
- For Unreal Engine, you can download the Puerts plugin from the Puerts GitHub repository.
-
Create a new TypeScript file in your project and import the necessary Puerts modules:
import * as csharp from 'csharp';
-
Expose your C++ or C# functions and classes to TypeScript by using the Puerts API:
// Expose a C++ function csharp.Puerts.TestClass.Register( 'Add', (a: number, b: number) => csharp.Puerts.TestClass.Add(a, b) ); // Expose a C# class csharp.Puerts.TestClass.Register(MyClass);
-
Call the exposed functions and use the exposed classes from your TypeScript code:
const result = csharp.Puerts.TestClass.Ad
Competitor Comparisons
A framework for building native Windows apps with React.
Pros of react-native-windows
- Specifically designed for Windows platform, offering native UI components and APIs
- Backed by Microsoft, ensuring long-term support and integration with Windows ecosystem
- Large community and extensive documentation for Windows-specific development
Cons of react-native-windows
- Limited to Windows platform, lacking cross-platform versatility
- Steeper learning curve for developers not familiar with Windows development
- May have performance overhead compared to native C++ development
Code Comparison
react-native-windows:
import { Text, View } from 'react-native';
import { Button } from 'react-native-windows';
const App = () => (
<View>
<Text>Hello, Windows!</Text>
<Button content="Click me" />
</View>
);
puerts:
import * as UE from 'ue'
class MyActor extends UE.Actor {
ReceiveBeginPlay(): void {
console.log("Hello, Unreal Engine!");
}
}
puerts.register(MyActor);
Key Differences
- react-native-windows focuses on building Windows applications using React Native
- puerts enables TypeScript/JavaScript development in Unreal Engine
- react-native-windows uses JSX for UI components, while puerts interacts with Unreal Engine's C++ API
- puerts offers broader game engine integration, while react-native-windows is tailored for Windows app development
A framework for building native applications using React
Pros of React Native
- Larger community and ecosystem, with more resources and third-party libraries
- Cross-platform development for iOS and Android with a single codebase
- Hot reloading for faster development and testing
Cons of React Native
- Steeper learning curve for developers new to React or mobile development
- Performance can be slower compared to native development, especially for complex apps
- Requires frequent updates to keep up with changes in iOS and Android platforms
Code Comparison
React Native:
import React from 'react';
import { View, Text } from 'react-native';
const App = () => (
<View>
<Text>Hello, React Native!</Text>
</View>
);
PuerTS:
import * as UE from 'ue'
class MyActor extends UE.Actor {
ReceiveBeginPlay(): void {
console.log("Hello, PuerTS!");
}
}
PuerTS focuses on integrating TypeScript with Unreal Engine, while React Native is a framework for building mobile applications using React. The code examples showcase their different use cases and syntax, with React Native using JSX for UI components and PuerTS utilizing TypeScript for game development in Unreal Engine.
Cocos simplifies game creation and distribution with Cocos Creator, a free, open-source, cross-platform game engine. Empowering millions of developers to create high-performance, engaging 2D/3D games and instant web entertainment.
Pros of cocos-engine
- Comprehensive game development framework with a rich set of tools and features
- Large and active community, providing extensive resources and support
- Cross-platform compatibility, allowing developers to target multiple platforms easily
Cons of cocos-engine
- Steeper learning curve due to its extensive feature set
- Potentially heavier resource usage compared to lightweight solutions
- May be overkill for simple projects or those not requiring a full game engine
Code Comparison
cocos-engine:
import { _decorator, Component, Node } from 'cc';
const { ccclass, property } = _decorator;
@ccclass('HelloWorld')
export class HelloWorld extends Component {
start() {
console.log('Hello, Cocos Creator!');
}
}
puerts:
import { FString, Actor } from 'ue'
class HelloWorld extends Actor {
Constructor() {
this.PrimaryActorTick.bCanEverTick = true;
}
ReceiveBeginPlay() {
console.log('Hello, Puerts!');
}
}
The code snippets demonstrate basic setup and logging in both frameworks. cocos-engine uses decorators and a component-based approach, while puerts integrates more closely with Unreal Engine's actor system.
Godot Engine – Multi-platform 2D and 3D game engine
Pros of Godot
- Complete game engine with built-in editor, rendering, physics, and more
- Large, active community with extensive documentation and tutorials
- Cross-platform support for multiple desktop and mobile platforms
Cons of Godot
- Steeper learning curve for developers new to game development
- Less flexible for integrating with existing C++ codebases
- Performance may be lower compared to native C++ engines for complex games
Code Comparison
Godot (GDScript):
extends Node2D
func _ready():
print("Hello, Godot!")
func _process(delta):
position += Vector2(1, 0) * delta
PuerTS (TypeScript):
import * as UE from 'ue'
class MyActor extends UE.Actor {
BeginPlay(): void {
console.log("Hello, PuerTS!");
}
Tick(DeltaSeconds: number): void {
this.AddActorWorldOffset(new UE.Vector(100, 0, 0).Multiply(DeltaSeconds));
}
}
Summary
Godot is a full-featured game engine suitable for various game types, while PuerTS focuses on integrating TypeScript into existing Unreal Engine projects. Godot offers a more comprehensive solution for game development but may have a steeper learning curve. PuerTS provides better performance and integration with C++ codebases but requires existing knowledge of Unreal Engine.
Kotlin/Native infrastructure
Pros of kotlin-native
- Supports multiple target platforms, including iOS, macOS, Windows, and Linux
- Seamless interoperability with existing native libraries and frameworks
- Strong static typing and null safety features inherited from Kotlin
Cons of kotlin-native
- Steeper learning curve for developers not familiar with Kotlin
- Limited JavaScript ecosystem integration compared to puerts
- Potentially larger binary sizes due to inclusion of Kotlin runtime
Code Comparison
kotlin-native:
fun main() {
println("Hello, Kotlin/Native!")
}
puerts:
console.log("Hello, PuerTS!");
Key Differences
- puerts focuses on TypeScript/JavaScript integration with game engines, while kotlin-native is a general-purpose native compilation solution for Kotlin
- kotlin-native provides direct compilation to native binaries, whereas puerts acts as a bridge between TypeScript/JavaScript and native environments
- puerts is specifically designed for game development scenarios, while kotlin-native has broader applications across various domains
Use Cases
- Choose kotlin-native for developing cross-platform native applications with Kotlin
- Opt for puerts when integrating TypeScript/JavaScript into game engines like Unreal Engine or Unity
Community and Support
- kotlin-native benefits from JetBrains' extensive support and the broader Kotlin community
- puerts has a growing community, particularly in the game development sector, with strong backing from Tencent
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
WHAT is PuerTS (PUER Typescript)?
PuerTS
is a TypeScript programming solution in Unity/Unreal/DotNet.
- provides a JavaScript Runtime.
- allows TypeScript to access the host engine with the help of TypeScript declarations generation.
WHY should I use PuerTS?
- Facilitates game-building processes by combining JavaScript/Node.js ecosystem and professional game engines
- In contrast to Lua script, TypeScript supports static type checking, which significantly improves code robustness and maintainability.
- High efficiency: supports reflection call throughout the host - no extra steps needed for interop with C++/C#.
- High performance: supports static wrapper generation - handles complex scenes with high-performance demands.
- Talented WebGL Support: massive advantage in performance and dev efficiency compared to Lua, even faster than pure C# in some cases.
HOW can I start to use PuerTS
FAQ
How to Install
Changelog
Known issues
Select Script Engine
Currently puerts supports three script engines: v8, quickjs, nodejs, choose the one that suits you.
-
V8 (default): Generally excellent performance, moderate code size, only includes the implementation of the ECMAScript specification, does not include Node.js API or browser API.
-
QuickJS: Performance is not as good as V8, does not support debugging, but has a small code size, suitable for scenarios where code size is critical.
-
Node.js: Supports Node.js API (OpenSSL-related APIs are not supported on Unreal Engine's mobile platform), but has a larger code size.
Script Engine | Node api | Performance | Code Size | Debugging | Notes |
---|---|---|---|---|---|
V8 | â | ***** | *** | âï¸ | |
QuickJS | â | ** | * | â | |
Node.js | âï¸ | ***** | ***** | âï¸ | OpenSSL may be disabled |
Avaliable on these Engine
-
unreal engine 4.22 ~ latest
-
unity 5 ~ latest
-
Any .net project
Available on these Platform
- iOS
- Android
- OpenHarmony
- Windows
- Macos
Ask for help
WHAT - æ®æ´±TSæ¯ä»ä¹?
PuerTSæ¯ Unity/Unreal/Dotnet ä¸çTypeScriptç¼ç¨è§£å³æ¹æ¡
- æä¾äºä¸ä¸ªJavaScriptè¿è¡æ¶
- æä¾TypeScript声ææ件çæè½åï¼æäºéè¿TypeScript访é®å®¿ä¸»å¼æï¼
WHY - 为ä»ä¹æ该ç¨æ®æ´±TS?
- JavaScriptçææä¼å¤çåºåå·¥å ·é¾ï¼ç»åä¸ä¸åä¸å¼æç渲æè½åï¼å¿«éæé 游æ
- ç¸æ¯æ¸¸æé¢å常ç¨çluaèæ¬ï¼TypeScriptçéæç±»åæ£æ¥æå©äºç¼åæ´å¥å£®ï¼å¯ç»´æ¤æ§æ´å¥½çç¨åº
- é«æï¼å ¨å¼æï¼å ¨å¹³å°æ¯æåå°è°ç¨ï¼æ éé¢å¤æ¥éª¤å³å¯ä¸å®¿ä¸»C++/C#éä¿¡ã
- é«æ§è½ï¼å ¨å¼æï¼å ¨å¹³å°æ¯æçæéæè°ç¨æ¡¥æ¢ï¼å ¼é¡¾äºé«æ§è½çåºæ¯ã
- WebGLå¹³å°ä¸ç天çä¼å¿ï¼ç¸æ¯Luaèæ¬å¨WebGLçæ¬ç表ç°ï¼PuerTSå¨æ§è½åæçä¸é½ææ大æåï¼ç®åæéæ åµçè³æ¯C#æ´å¿«ã
HOW - æ该æä¹å¼å§
常è§é®é¢
ææ°çæ¬å®è£
æ¹å¨æ¥å¿
å·²ç¥é®é¢ä¸è§£å³åæ³
èæ¬å¼æéæ©
ç®åpuertsæ¯æä¸ç§èæ¬å¼æï¼v8ãquickjsãnodejsï¼éæ©åéä½ çé£ä¸ªã
-
v8ï¼é»è®¤ï¼ï¼ç»¼åæ¯è¾ä¼ç§ï¼é«æ§è½ï¼ä»£ç ä½ç§¯éä¸ï¼ä» å å«ecmascriptè§èçå®ç°ï¼ä¸å å«nodejs apiãæµè§å¨ api
-
quickjsï¼ æ§è½ä¸å¦v8ï¼ä¸æ¯æè°è¯ï¼ä½ä»£ç ä½ç§¯å°ï¼éç¨äºä»£ç 段大å°ææåä¸å¡
-
nodejsï¼æ¯ænodejs apiï¼unreal engineç移å¨å¹³å°ä¸ä¸æ¯æopensslç¸å ³apiï¼ï¼ä»£ç ä½ç§¯è¾å¤§
èæ¬å¼æ | Node api | æ§è½ | 代ç ä½ç§¯ | è°è¯ | è¡¥å |
---|---|---|---|---|---|
V8 | â | ***** | *** | âï¸ | |
QuickJS | â | ** | * | â | |
Node.js | âï¸ | ***** | ***** | âï¸ | OpenSSL å¯è½è¢«ç¦ç¨ |
å¯ç¨å¼æ
-
unreal engine 4.22 ~ latest
-
unity 5 ~ latest
-
ä»»æ.netç¯å¢
å¯ç¨å¹³å°
- iOS
- Android
- 鸿èï¼OpenHarmonyï¼
- Windows
- Macos
ææ¯æ¯æ
QQ群ï¼942696334
UE4ä¸å±ç¾¤ï¼689643903
å¼åå客
Top Related Projects
A framework for building native Windows apps with React.
A framework for building native applications using React
Cocos simplifies game creation and distribution with Cocos Creator, a free, open-source, cross-platform game engine. Empowering millions of developers to create high-performance, engaging 2D/3D games and instant web entertainment.
Godot Engine – Multi-platform 2D and 3D game engine
Kotlin/Native infrastructure
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot