Skip to main content

Hello World Example

Follow along these steps to learn how to create a new TypeScript file and have it execute code.

Create a TypeScript File

In the Project window, open the Assets > Experience folder. Right click anywhere and select GENIES > Scripting > Create Genies Behavior Script.

Create TypeScript

note

All custom TypeScript files need to be placed in the Assets > Experience folder.

Name the File

Name the newly created script file HelloWorld.

Name File

Add File to an Object

Create an empty GameObject in the Hierarchy window. Select the GameObject and open the Inspector window. Drag and drop the HelloWorld script as a component to his object.

TypeScript Component

Add Code to the File

Double click the HelloWorld script to open your IDE (preferably VS Code).

Replace the code inside the file with this:

import { MonoBehaviour } from "UnityEngine";

export default class HelloWorld extends MonoBehaviour {
private Start() : void {
console.log("Hello World");
}
}

Test the Project

Save the code. Return to Unity and enter the Play button. The Console window should display the message.

Console Output

Infinite Runner Tutorial

Check out the Infinite Runner tutorial to see an example game using TypeScript.

Infinite Runner