vendredi 5 octobre 2018

Hosting Unity WebGL Game using Laravel Framework

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 ]

  1. I built a Unity game in WebGL
  2. I put the built folder in xampp/htdocs directory
  3. I run xampp, then turn on apache server
  4. I open my browser and went to localhost/mygamefolder
  5. 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 ]

  1. I put the built folder into mylaravelproject/public directory
  2. I copied the content of index.html file from the Unity built project and paste it in one of my views file (.blade.php).
  3. I changed the stylesheet and references at the tag according to the path where I put the built folder is.
  4. I open the terminal and run 'php artisan serve'
  5. I open browser and go to the IP address as shown in the terminal
  6. 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)
  7. 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.

Aucun commentaire:

Enregistrer un commentaire