Reputation: 178
I have a two separate webGL games that built with unity. Which can be uploaded to a Game portal website. One of two games is a 3d game, which player can walk around to places and interact with some objects. When player interact with it, I want to load the other game inside the same page. I want to do this process backwards as well. I tried to do this with, adding the two games into the same project. I have lot of problems when doing it.
Can anyone give me a solution for this? Any comments would be highly appreciated.
Upvotes: 0
Views: 570
Reputation: 386
If you take a look at your built WebGL game you'll see an index.html
file. You will need to take both of your built games and put them in a folder and create a new index.html
(based off of the ones that your WebGL build contain) that will properly load two unityInstance
s on the same page.
To accomplish this, you will need to change some of your IDs so that the two scripts don't interact with the same DOM elements; and you will need to change the file paths of your built game so that it can access the game even though it's now in a folder.
It's not an easy challenge, and unfortunately, it might require some trickery to get automated. You could also try loading the WebGL project JavaScript or an iFrame
.
There is a minimum size that a Unity WebGL project can be (around 10mb), so it's not going to scale up to 20-30 games on a single page. For comparison, a typical webpage is ~2mb nowadays. You are going to have to load them one-at-a-time.
Upvotes: 1