react-unity-webgl
Advanced tools
Comparing version 5.6.0-update.3 to 5.6.0-update.4
@@ -28,2 +28,4 @@ "use strict"; | ||
module.exports.UnityInstance.SendMessage(gameObjectName, methodName, paramterValue); | ||
} else { | ||
console.warn("react-unity-webgl: you've sent a message to the " + "unity content, but it wasn't instantiated yet."); | ||
} | ||
@@ -58,5 +60,15 @@ }; | ||
if (typeof UnityLoader === 'undefined') { | ||
var errorText = "The UnityLoader was not defined, please add the script tag " + "to the base html and embed the UnityLoader.js file Unity exported."; | ||
console.error(errorText); | ||
this.setState({ | ||
error: errorText | ||
}); | ||
return; | ||
} | ||
if (this.props.src == null) { | ||
var _errorText = "Please provice a path to a valid JSON in the 'src' attribute."; | ||
console.error(_errorText); | ||
this.setState({ | ||
error: "Please provice a path to a valid JSON in the 'src' attribute." | ||
error: _errorText | ||
}); | ||
@@ -89,3 +101,3 @@ return; | ||
"div", | ||
{ className: "unity-container" }, | ||
{ className: "unity" }, | ||
_react2.default.createElement( | ||
@@ -92,0 +104,0 @@ "b", |
{ | ||
"name": "react-unity-webgl", | ||
"version": "5.6.0-update.3", | ||
"version": "5.6.0-update.4", | ||
"description": "A Unity WebGL component for your React application", | ||
@@ -5,0 +5,0 @@ "main": "lib/react-unity-webgl.js", |
# react-unity-webgl | ||
A Unity WebGL component for your React application. | ||
Easy to use Unity 5.6 or newer WebGL player component for your React application. Embed your Unity application in your react application for writing interactive interfaces with two way Unity and react communication. | ||
<img src="http://react-etc.net/files/2016-07/logo-578x270.png" height="50px"/> <img src="http://gamepadable.com/wp-content/uploads/2016/01/Official_unity_logo.png" height="50px"/> | ||
# installation | ||
@@ -15,5 +17,7 @@ Install using npm. Make sure you download the version matching with your Unity version. I try to update this plugin in case of need as fast as possible. | ||
> Don't forget to add a script tag to load the `UnityLoader.js` file, exported by Unity in your base html file. | ||
```js | ||
import React, { Component } from 'react'; | ||
import { Unity } from '/Projects/react-unity-webgl'; | ||
import { Unity } from 'react-unity-webgl'; | ||
@@ -23,3 +27,3 @@ export class App extends Component { | ||
return (<div className="app"> | ||
<Unity src="Build/viewer.json" /> | ||
<Unity src="Build/myGame.json" /> | ||
</div>) | ||
@@ -35,3 +39,3 @@ } | ||
import React, { Component } from 'react'; | ||
import { Message } from '/Projects/react-unity-webgl' | ||
import { Message } from 'react-unity-webgl' | ||
@@ -70,2 +74,2 @@ export class Menu extends Component { | ||
} | ||
``` | ||
``` |
@@ -12,2 +12,5 @@ import React, { Component } from 'react'; | ||
paramterValue); | ||
} else { | ||
console.warn ("react-unity-webgl: you've sent a message to the " | ||
+ "unity content, but it wasn't instantiated yet.") | ||
} | ||
@@ -29,12 +32,23 @@ }); | ||
instantiateUnityLoader () { | ||
if (typeof UnityLoader === 'undefined') { | ||
let errorText = "The UnityLoader was not defined, please add the script tag " + | ||
"to the base html and embed the UnityLoader.js file Unity exported."; | ||
console.error(errorText); | ||
this.setState({ | ||
error: errorText | ||
}); | ||
return; | ||
} | ||
if (this.props.src == null) { | ||
let errorText = "Please provice a path to a valid JSON in the 'src' attribute."; | ||
console.error(errorText); | ||
this.setState({ | ||
error: "Please provice a path to a valid JSON in the 'src' attribute." | ||
error: errorText | ||
}); | ||
return; | ||
} | ||
let instance = UnityLoader.instantiate ( | ||
let instance = UnityLoader.instantiate( | ||
"unity-container", | ||
this.props.src, { | ||
onProgress: ((gameInstance, progress) => { | ||
onProgress:((gameInstance, progress) => { | ||
this.setState({ | ||
@@ -50,5 +64,5 @@ loaded: progress == 1, | ||
if (this.state.error == null) { | ||
return this.onLoadedRender (); | ||
return this.onLoadedRender(); | ||
} else { | ||
return this.onUnableToRender (); | ||
return this.onUnableToRender(); | ||
} | ||
@@ -58,3 +72,3 @@ } | ||
return ( | ||
<div className="unity-container"> | ||
<div className="unity"> | ||
<b>React-Unity-Webgl error</b>: | ||
@@ -61,0 +75,0 @@ {this.state.error} |
12983
207
72