Play Unity games through your browser
Here are a few ways how to embed GameLoad on your website:
1. a simple link to download the program and play the game
2. modifying the code for the Unity Web Player and detect Chrome
Properties
1. a simple link to download the program and play the game
You have to change values of variables. Also you can modify content of document.write, but be sure, that the link to play the game will be:
gameload://' + insert_data + '/
See it in action
Only for Chrome and Edge users:
<script>
var myJsonString = JSON.stringify({ title: 'Game Title', file: 'http://www.gamesflare.org/games/2013-1/traffic-talent.unity3d', type: "unity", width: 800, height: 600 });
try{ //IE8 does not support window.btoa
var insert_data = window.btoa(myJsonString);
}catch(e){
functionToHandleError(e);
}
document.write('<center><a href="gameload://' + insert_data + '/"><img alt="Play game with Gameload!" src="http://data.gameload.top/download/playgameload.png" /></a><br /><br />Install Gameload to play Unity games<br /><a href="http://data.gameload.top/download/gameload.exe" title="Install Gameload now!"><img alt="Install Gameload now!" src="http://data.gameload.top/download/getgameload.png" /></a></center>');
</script>
2. modifying the code for the Unity Web Player and detect Chrome
If the user is using Chrome, instead of installation of the Unity Web Player, the script will display installation of GameLoad and also the Play button to start the game.
See it in action
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-browser/0.0.8/jquery.browser.min.js"></script>
<script>
$(document).ready(function(){
if ($.browser.chrome === true && $.browser.versionNumber >= 45) { //detect Chrome 45+
var myJsonString = JSON.stringify({ title: 'Game Title', file: 'http://www.gamesflare.org/games/2013-1/traffic-talent.unity3d', type: "unity", width: 800, height: 600 });
try{ //IE8 does not support window.btoa
var insert_data = window.btoa(myJsonString);
}catch(e){
functionToHandleError(e);
}
$('#unityPlayer .missing').prepend('<center><a href="gameload://' + insert_data + '/"><img alt="Play game with Gameload!" src="http://data.gameload.top/download/playgameload.png" /></a><br /><br />Install Gameload to play Unity games<br /><a href="http://data.gameload.top/download/gameload.exe" title="Install Gameload now!"><img alt="Install Gameload now!" src="http://data.gameload.top/download/getgameload.png" /></a></center>');
}
});
</script>
<div id="unityPlayer">
<div class="missing"></div>
</div>
Properties
Name | Type | Description |
---|---|---|
width | integer | Width of game |
height | integer | Height of game |
file | string | Url of game |
type | string | There are three types: unity, flash, iframe |
title | string | Title of game |