Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Tip

Available since version 11.0 (Paper Plane)

It’s also possible to embed Unity in an External application front-end can embed Pricefx front-end. Pricefx front-end will be then rendered inside of an iframe of the external application.

This enables Unity to be used in other platforms, and also there is messaging support through the usage of postMessage method (https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage). In order to use it, please check it here: Messaging API.

Below, you can find a simple example of its implementation.

Implementation example

As you embed Unity inside another is an example how to embed Pricefx inside an external application:

Code Block
languagehtmlxml
<iframe
  src = "https://{partition}.pricefx.com"
  id = "pfx-iframe"/>

You can start using it with the code below:

Code Block
languagejs
const
iframe = document.getElementById('pfx-iframe');
const messageHandler = (event) => console.log(event.data);
window.addEventListener(messageHandler);
iframe.contentWindow.postMessage({
  "source": "pfxParentMessage",
  "type": "getUserData"
}, *);

In this case, you will attach a handler that logs the message it receives from Unity, and also will message Unity requesting the logged in user data.

On the other side, if you have an external application embedded in Unity:

Code Block
languagejs
const messageHandler = (event) => console.log(event.data);
window.addEventListener(messageHandler);
window.parent.postMessage({
  "source": "pfxParentMessage",
  "type": "getUserData"
}, *);

...

 sandbox = "allow-forms allow-modals allow-popups allow-same-origin allow-scripts"
/>

Parameters for the iframe:

Parameter

Description

src

URL for Pricefx.

id

(optional) Used to target the proper iframe with messages. The value is decided by the external application embedding Pricefx .

sandbox

(optional) If the external application uses this setting, make sure that at least the minimum permissions needed by Pricefx front-end are provided: allow-forms allow-modals allow-popups allow-same-origin allow-scripts

The external application front-end can communicate with Pricefx front-end through the Unity Messaging API.