Skip to content

super-reality/sr-legacy-unity-vfx

Repository files navigation

Super Reality Unity Tools

Overlays

Folder structure

  • Build/ - unity stuff
  • data.json - exposed metadata for editor use
  • index.html - the overlay file to render
  • thumbnail.### - preview thumbnail image (use metadata to get the path)

Exposed metadata

  • id - autogenerated id
  • name - overlay name
  • thumbnail - relative path to thumbnail from root
  • tags - array of tag name strings
  • parameters - array of parameter names and types
    • (array item)
      • name - parameter name
      • type - parameter type
  • actions - array of action names
    • (array item)
      • name - action name

Sending messages with window.postMessage()

Messages are formatted similarly to Redux actions.

window.postMessage(
    {
        type: "MESSAGE",
        payload: {
            // ...
        }
    }
)

Once the DOM is ready, messages can be received and processed, even while Unity loads.

Messages received while Unity loads are buffered, then sent in the order received.

Parameters

Payload structure

window.postMessage(
    {
        type: "SET_<TYPE>_PARAMETER",
        payload: {
            name: "Parameter Name",
            // see examples below for the value property
        }
    }
)

Available types

Data Type Message Type Value Structure Notes
bool SET_BOOL_PARAMETER {value: false}
int SET_INT_PARAMETER {value: 0}
float SET_FLOAT_PARAMETER {value: 0.0}
string SET_STRING_PARAMETER {value: ""}
Vector2 SET_VECTOR2_PARAMETER {value: {x: 0.0, y: 0.0}} Components are floats
Vector3 SET_VECTOR3_PARAMETER {value: {x: 0.0, y: 0.0, z: 0.0}} Components are floats
Color SET_COLOR_PARAMETER {value: {r: 0.0, g: 0.0, b: 0.0, a: 0.0}} Components are floats ranging from 0.0 to 1.0
Color32 SET_COLOR32_PARAMETER {value: {r: 0, g: 0, b: 0, a: 0}} Components are ints ranging from 0 to 255

Example: Setting a Color32 parameter

window.postMessage(
    {
        type: "SET_COLOR32_PARAMETER",
        payload: {
            name: "Background Color",
            value: {
                r: 0,
                g: 199,
                b: 172,
                a: 255
            }
        }
    }
);

Actions

Payload structure

window.postMessage(
    {
        type: "RUN_ACTION",
        payload: {
            name: "Action Name"
        }
    }
)

Example: Running a Start action

window.postMessage(
    {
        type: "RUN_ACTION",
        payload: {
            name: "Start"
        }
    }
);

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages