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 ]
- I built a Unity game in WebGL
- I put the built folder in xampp/htdocs directory
- I run xampp, then turn on apache server
- I open my browser and went to localhost/mygamefolder
- It works fine, but this is using xampp
Now what I want is, how to test if the game works using server hosted using Laravel framework...
[ What I did ]
- I put the built folder into mylaravelproject/public directory
- I copied the content of index.html file from the Unity built project and paste it in one of my views file (.blade.php).
- I changed the stylesheet and references at the tag according to the path where I put the built folder is.
- I open the terminal and run 'php artisan serve'
- I open browser and go to the IP address as shown in the terminal
- I went to the page where I put the game, but the game does not load. (Game only, other thing like navbar and button I put etc works fine)
- I open console, it said:
- "Uncaught ReferenceError: UnityLoader is not defined
- "Failed to load resource: the server responded with a status of 404 (Not Found)" at demo:15"
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>