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 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.
Both QuickJS
and V8
are tested on mobile, but V8 is definitely the more stable and performant choice for older devices and OS’s. 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
bundle.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 Off
If you have “Enable For Standalone” ticked on the Runner
component, make sure to turn it off. This will save some CPU cycles for you since, in most cases, Live Reload will be unnecessary for Standalone.
link.xml
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:
<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
, notlinker.xml
orlinks.xml
. - Make sure the extension is
.xml
and not something like.xml.txt
. - The root xml node has to be named
<linker>
.