00:00
00:00
Newgrounds Background Image Theme

Jmurr12 just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

help with JS / CSS for Unity WebGL

1,404 Views | 2 Replies
New Topic Respond to this Topic

TL;DR: my loading bar on unity webGL player is crap

i choose this tutorial (out of others):

https://ocias.com/blog/unity-webgl-custom-progress-bar/

after updating css i ended up with UnityProgress.js:

function init()
{

}

function UnityProgress(dom)
{
	this.progress = 0.0;
	this.message = "";
	this.dom = dom;

	createjs.CSSPlugin.install(createjs.Tween);
	createjs.Ticker.setFPS(60);

	var parent = dom.parentNode;

	this.SetProgress = function (progress)
	{
	    if (this.progress < progress)
	    {
			this.progress = progress;
	    }

	    if (progress == 1)
	    {
	        this.SetMessage("Preparing...");
	        document.getElementById("spinner").style.display = "inherit";
	        document.getElementById("bgBar").style.display = "none";
	        document.getElementById("progressBar").style.display = "none";
	    }

		this.Update();
	}

	this.SetMessage = function (message)
	{
		this.message = message; 
		this.Update();
	}

	this.Clear = function ()
	{
	    document.getElementById("loadingBox").style.display = "none";
	}

	this.Update = function ()
	{
	    var length = 200 * Math.min(this.progress, 1);
	    bar = document.getElementById("progressBar");
	    bar.style.width = length + "px";
	    createjs.Tween.removeTweens(bar);
	    createjs.Tween.get(bar).to({ width: length }, 500, createjs.Ease.sineOut);
	    document.getElementById("loadingInfo").innerHTML = this.message;
	}

	this.Update();

}

the loading bar is still really slow even thought it worked fast for the sites in the tutorial but not for mine here on newgrounds

the demo for seeing the loading bar (if u want):

Response to help with JS / CSS for Unity WebGL 2017-08-16 12:48:50


I'm on mobile, so I cannot check. But if that's the tutorial I'm thinking it is, it's outdated and only worked for the previous versions of unity. If you manage to get it to work, give me a shout :)


This is what I'm using:
https://www.newgrounds.com/dump/download/dfc9e336f62d53f0c31de5336098e096

Dump the folder in to your unity project and select the template you want when you build. Replace img.jpg with a picture of your choosing.