Search code examples
reactjsunity-game-enginereduxunity-webgl

Integration of react / redux and unity for web game developement


is there a way to integrate unity with react in a web application? Maybe even run the unity part in a subwindow.

So basically I want to use the unity part of the graphics and animations. If something interesting happens in the game, then the state in the react / redux is changes or some action is triggered.

It would be ideal if I could use some parts of the redux state in the unity part of the game. So access redux or some parts via handlers in unity.

Thanks a lot. I hope it is clear what I want to do.


Solution

  • Yes, this is possible. I've made a library for archiving this, you can get it from here. I've added two way communication between your React and Unity content.

    You can load your Unity content as following.

    export class App extends React.Component {
      render () {
        return <Unity 
          src='Public/Build/myGame.json' 
          loader='Public/Build/UnityLoader.js' />
      }
    }
    

    If you have any further questions you can open an issue on the GitHub page.