How do I put my Unity game built in WebGL into Laravel?
FYI, Unity WebGL, when built gives me these files: - Build (folder) - TemplateData (folder) - index.html
Let me tell what I have done:
[ How I test if the game works in WebGL using XAMPP ]
Now what I want is, how to test if the game works using server hosted using Laravel framework...
[ What I did ]
Any ideas? Or if you can direct me to tutorial on how to put your Unity WebGL game into Laravel that would be good. Since I tried to search for it and so far I found nobody is putting Unity in their Laravel website.
--- Edit: Here is the index.html file as produced by Unity WebGL ---
<!DOCTYPE html>
<html lang="en-us">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Unity WebGL Player | Projectile</title>
<link rel="shortcut icon" href="TemplateData/favicon.ico">
<link rel="stylesheet" href="TemplateData/style.css">
<script src="TemplateData/UnityProgress.js"></script>
<script src="Build/UnityLoader.js"></script>
<script>
var gameInstance = UnityLoader.instantiate("gameContainer", "Build/OrangeCodeGame.json", {onProgress: UnityProgress});
</script>
</head>
<body>
<div class="webgl-content">
<div id="gameContainer" style="width: 960px; height: 600px"></div>
<div class="footer">
<div class="webgl-logo"></div>
<div class="fullscreen" onclick="gameInstance.SetFullscreen(1)"></div>
<div class="title">Projectile</div>
</div>
</div>
</body>
</html>
In version 2021.2, Unity marked support for the WebGL 1 Graphics API as deprecated. In Unity 2021.2, there are no changes in behavior and Unity still includes the WebGL 1 Graphics API if you enable the Auto Graphics API Player Setting.
Unity Technologiesyes, Build and Run works.
First you need to install a plugin from Unity called unity web player. Then export your game to the web format, i think it is the first option in the build menu. You upload it to your server and just play.
Figured it out:
When you build Unity game with WebGL, Unity will provide this files:
Done, now it will works fine. You can even put Laravel content inside the index.blade.php of unity with your navbar or anything you like.
Plus, the authentication session can also be passed normally.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With