@Singtaa: Please consider leaving a review on the Asset Store if you enjoy using OneJS. It really helps us a lot! And, I promise it'll take less time than debugging your last script.😊 Oh also, OneJS V2 is now out of preview!
VERSION
Doc Menu

Deployment

OneJS has been tested on Windows, Mac, iOS, and Android. WebGL support is planned for the future. Generally, no extra steps are needed when building your standalone player with an OneJS project. Everything is set up so you can follow the standard Unity build workflow, and it will work seamlessly.

Backends

By default, OneJS (v2) uses QuickJS due to its small footprint. You can quickly switch the backend (QuickJS, V8, or NodeJS) using npm run switch, but make sure the Unity editor is closed before doing so. V8 is more performant and has a much higher recursion limit than QuickJS.

Both QuickJS and V8 are tested on mobile devices. Be sure to set the correct architecture in Player Settings before building (e.g., check both ARMv7 and ARM64).

Bundler

The Bundler component (on ScriptEngine) takes care of 3 things:

  • Setting up OneJS for the first time by copying essential files into your Working Directory when the files are not found.
  • Bundling your scripts at buildtime (into outputs.tgz).
  • Extracting the bundle at runtime for your standalone Player.

The bundling and extraction process are both automatic so you don't need to worry about it too much. One thing worth mentioning is that the outputs.tgz file can be zero'ed out via the context menu so you don't need to keep checking it into git, for example.

Live Reload, on or off

For production deployment where you don't need Live Reload, remember to turn it off by unchecking the "Enable For Standalone" option on the Runner component (if you had it on before). This will save some CPU cycles for you since, in most cases, Live Reload will be unnecessary for Standalone.

link.xml for AOT Platforms and IL2CPP

AOT Platforms and IL2CPP builds will strip all your unused C# code. So for all the classes you'd like to call dynamically from Javascript, you'd need to preserve them. link.xml will do the job. Here's an example:

XML
<linker>
    <assembly fullname="mscorlib" preserve="all" />
    <assembly fullname="OneJS" preserve="all" />
    <assembly fullname="UnityEngine.CoreModule" preserve="all" />
    <assembly fullname="UnityEngine.PhysicsModule" preserve="all" />
    <assembly fullname="UnityEngine.TextRenderingModule" preserve="all" />
    <assembly fullname="UnityEngine.UIElementsModule" preserve="all" />
    <assembly fullname="UnityEngine.IMGUIModule" preserve="all" />
    <assembly fullname="Unity.Mathematics" preserve="all" />
</linker>

Folks tend to run into problems when dealing with link.xml for the first time. So here are some tips.

  • The file name has to be link.xml, not linker.xml or links.xml.
  • Make sure the extension is .xml and not something like .xml.txt.
  • The root xml node has to be named <linker>.