Skip to content

Communication between Unity and React

Gökhan Kurt edited this page Apr 22, 2021 · 3 revisions

Although there are various ways to do this for advanced use cases, the easiest way is by using the Globals object. Globals is a dictionary of Unity objects you can send over to the React side from the Unity side.

You can set Globals in the inspector:

inspector

After assigning, you can access your object in React side via the Globals global variable. Here is an example script using Globals. You can download the full sample project to see this in action.

example

Note: You can set/get an object's public properties and call its public methods from React side. However, if you try to set/get a non-existing or non-public property/method, you will get an error.