Skip to content

Commit

Permalink
Updated readme
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffreylanters committed Dec 6, 2017
1 parent 5f6ab8b commit f2f0440
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ $ npm install react-unity-webgl
To get started import the default Unity class from react-unity-webgl and include it in your render while giving the public path to your src and loader files.

```js
import React from 'react';
import Unity from 'react-unity-webgl';
import React from 'react'
import Unity from 'react-unity-webgl'

export class App extends React.Component {
render () {
Expand Down Expand Up @@ -91,12 +91,12 @@ SendMessage (objectName, methodName, value);

Where objectName is the name of an object in your scene; methodName is the name of a method in the script, currently attached to that object; value can be a string, a number, or can be empty. For example:
```js
import React from 'react';
import { SendMessage } from 'react-unity-webgl';
import React from 'react'
import { SendMessage } from 'react-unity-webgl'

export class App extends React.Component {
spawnEnemy (count) {
SendMessage ('SpawnBehaviour', 'SpawnEnemies', count);
SendMessage ('SpawnBehaviour', 'SpawnEnemies', count)
}
render () {
return <div onClick={ this.spawnEnemy.bind(this, 5) }>
Expand Down Expand Up @@ -126,15 +126,15 @@ RegisterExternalListener (methodName, callback);
```
Where methodName is the name of a method in the script, this method will be binded to the current browser window so Unity can refer to it; callback canwill be a function, which takes one parameter with the value passed by your content. Note that it is recommended to register the callbacks before loading the Unity content. For example:
```js
import React from 'react';
import { RegisterExternalListener } from 'react-unity-webgl';
import React from 'react'
import { RegisterExternalListener } from 'react-unity-webgl'

export class App extends React.Component {
constructor () {
RegisterExternalListener ('OpenMenu', this.openMenu.bind (this));
RegisterExternalListener ('OpenMenu', this.openMenu.bind (this))
}
openMenu (menuId) {
console.log (`opening menu with id ${menuId$}`);
console.log (`opening menu with id ${menuId$}`)
}
}
```
Expand Down

0 comments on commit f2f0440

Please sign in to comment.