Official Puerts Demos?
Bellow is a list of demo projects that cover all of the different features Puerts has to offer.
Setup
Download one of the demo projects below
Setup the Puerts plugin inside of the demo project using the official installation guide.
Note: Installing the NodeJS
script backend is recommended for all demo projects.
Projects
- Manually Starting A JavasScript Virtual Machine
- Automatic Binding Mode
- Debugging With VSCode
- C++ calling TypeScript
- Combining TypeScript and C++ Classes With Mixin
- Interacting With Non-Reflected API Through Template Based Static Binding
Legacy Projects (Potentially Outdated)
How to Run:
To run a specific TypeScript example, change the entry in TsGameInstance.cpp to the desired script name (without the .ts
extension). By default, it runs QuickStart
.
Manually Creating a Virtual Machine
You can manually construct one or more virtual machines.
- Virtual Machine Example Project: Demonstrates how users can create their own VM.
- TsGameInstance.cpp: Shows how to construct a VM inside
GameInstance
(you can also create it in other classes as needed).
- TsGameInstance.cpp: Shows how to construct a VM inside
Inheriting Engine Classes
- FPS Demo: A first-person shooter game example demonstrating how to use Puerts' "Inherit Engine Class" feature. More details can be found in the Unreal Manual.
When this feature is enabled, the system automatically starts a default VM as the runtime environment for TypeScript classes that inherit from engine classes. Note that if you start additional VMs, they will be isolated from each other.
TypeScript and Engine/C++ Interaction Examples
Although the following examples are part of the Virtual Machine Example Project, they can be run in any VM environment.
QuickStart.ts: Demonstrates mutual calls between TypeScript and the Unreal Engine.
- In TypeScript classes that inherit engine classes, calling
argv.getByName("GameInstance")
will returnundefined
because this argument isn’t passed into the default VM by default.
- In TypeScript classes that inherit engine classes, calling
NewContainer.ts: Demonstrates container creation.
AsyncTest.ts: Demonstrates how to load a Blueprint asynchronously and wrap a
Delay
into anasync/await
call.UsingWidget.ts: Demonstrates UI loading, event binding, and data access.
UsingMixin.ts: Demonstrates the mixin functionality.
Calling regular C++ classes:
- TestClass.h: Basic example of a C++ class definition.
- AdvanceTestClass.h: Advanced C++ class example.
- TestClassWrap.cpp: Binding declarations (to export C++ classes to TypeScript).
- CDataTest.ts: Demonstrates calling C++ from TypeScript.
Editor Extensions
Puerts can also be used to write editor extensions. If you use the Node.js version of Puerts, you can leverage a wide variety of npm packages to speed up editor development.
- Editor Extension Demo Project
- Main.ts: Demonstrates menus, toolbars, dropdown buttons, right-click context menus, and command-line extension.
- DemoWindow.ts: Demonstrates (optional) IMGUI usage.
- NodejsDemo.ts: Demonstrates usage of Node.js APIs.