Skip to content

how to facilitate React to Unity communication in a component without rendering unity webgl player #159

Discussion options

You must be logged in to vote

Hi @gjagnoor, the requested behaviour came available in version 8.2.0 of the module. See the example below. The example below keeps the Unity component hidden until the Unity application is completely loaded and running.

import React, { Component } from "react";
import Unity, { UnityContext } from "react-unity-webgl";

class App extends Component {
  public state = {
    isLoaded: false,
  };

  private unityContext = new UnityContext({
    loaderUrl: "build/myunityapp.loader.js",
    dataUrl: "build/myunityapp.data",
    frameworkUrl: "build/myunityapp.framework.js",
    codeUrl: "build/myunityapp.wasm",
  });

  public componentDidMount(): void {
    this.unityContext.on("loaded", () => t…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by jeffreylanters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #141 on March 05, 2021 10:00.