This sample is available as a public repo at https://github.com/DragonGround/FortniteSample
Step-by-step Setup
- Extract this repo to
{ProjectDir}/OneJS/ForniteSample
- Under
{ProjectDir}/OneJS
, make aindex.tsx
file like below:
import { render, h } from "preact"
import FortniteSample from "FortniteSample"
import { update } from "tweenjs/tween"
render(<FortniteSample />, document.body)
function animate(time) {
requestAnimationFrame(animate)
update(time)
}
requestAnimationFrame(animate)
- Open
{ProjectDir}/OneJS
with VSCode and run thetsc: watch
task (Ctrl + Shift + B) - In Unity, drag a ScriptEngine prefab onto the scene.
- Import the included
CharacterManager.cs
file into Unity and drag the MonoBehaviour onto a scene. - Then include
CharacterManager
into the Objects list under ScriptEngine's INTEROP; name it tocharman
- Make sure Live Reload's entry script is set to
index.js
. - Hit Play and you should be all set
Everytime you checkout a new OneJS version (from the private repo or Asset Store), make sure you also update your ScriptLib folder. You can do so by deleting the old one, a new one will be automatically created upon running ScriptEngine. This step will be automated in the future.