Hello World Example
Follow along these steps to learn how to create a new TypeScript file and have it execute code.
Create a New Scene
Open a Unity project that contains the Genies SDK and create a new scene.
Check out the Getting Started tutorial if you need help creating a Unity project that contains the Genies SDK.
Create a TypeScript File
In the Project window, open the Assets > Experience folder. Right click anywhere and select GENIES > Scripting > Create Genies Behavior Script.
All custom TypeScript files need to be placed in the Assets > Experience folder.
Name the File
Name the newly created script file HelloWorld
.
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.
Add Code to the File
Double click the HelloWorld script to open 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.
Next Steps
Check out the Infinite Runner tutorial to see an example game using TypeScript.