Use the /collab command on Discord to gain access to the OneJS private repo. The repo offers early access to the latest features and fixes that may not yet be available on the Asset Store. An early preview of OneJS V2 is available on branch onejs-v2. It brings major performance improvements, zero-allocation interop, and a new esbuild workflow.
Doc Menu


OneJS's Dom is a thin wrapper over the underlying VisualElement. Dom basically implements the mininum amount of features that's required from Preact.

The Dom object has 2 properties that are worth mentioning. One is, the other is is useful for grabbing the actual VisualElement. But because VisualElement is from C#/.Net, sometimes working with it can be a bit verbose. For example, to set the rotate style for a VisualElement, you'd need to do:

TSX = new StyleRotate(new Rotate(new Angle(-36)))

Which is fairly tedious to write. This is where comes in. It's a convenience wrapper over the counterpart. So you can just do this:

TSX = -36

Full code example:

import { h, render } from "preact"
import { Dom } from "OneJS/Dom"
import { useRef, useEffect } from "preact/hooks"
import { Angle, Rotate, StyleRotate } from "UnityEngine/UIElements"

const App = () => {
    const ref = useRef<Dom>()

    useEffect(() => {
        // ref.current returns the Dom object
        // returns the underlying VisualElement

        // Both the following lines do the same thing = new StyleRotate(new Rotate(new Angle(-36))) = -36
    }, [])

    return <div ref={ref}>Hello</div>

render(<App />, document.body)