Be a Supporter!

Unity3d WebGL Support

  • 15,076 Views
  • 55 Replies
New Topic Respond to this Topic
PsychoGoldfish
PsychoGoldfish
  • Member since: Sep. 26, 2000
  • Offline.
Forum Stats
Staff
Level 12
Programmer

Having problems with your Unity3D WebGL game? Please start here. If you've read through the wiki, searched Google, etc. and still haven't resolved your issue, feel free to ask a question here.


Arch-Angel likes this sig!

BBS Signature
MSGhero
MSGhero
  • Member since: Dec. 15, 2010
  • Offline.
Forum Stats
Member
Level 16
Game Developer
Response to Unity3d WebGL Support 2015-05-13 16:24:36 (edited 2015-05-13 16:26:00) Reply

At 5/13/15 12:02 PM, PsychoGoldfish wrote: You can add other key codes to the ignore_keycodes array as needed.

Is there a way to do this to ignore scroll wheel inputs? In flash, you have to send js to the browser, and it doesn't work on every browser or every OS.

I don't use js or html5 so I wouldn't know if it was obvious. It'd be something I add post-haxe output.
PsychoGoldfish
PsychoGoldfish
  • Member since: Sep. 26, 2000
  • Offline.
Forum Stats
Staff
Level 12
Programmer
Response to Unity3d WebGL Support 2015-05-13 19:39:44 Reply

At 5/13/15 04:24 PM, MSGhero wrote:
At 5/13/15 12:02 PM, PsychoGoldfish wrote: You can add other key codes to the ignore_keycodes array as needed.
Is there a way to do this to ignore scroll wheel inputs? In flash, you have to send js to the browser, and it doesn't work on every browser or every OS.
I don't use js or html5 so I wouldn't know if it was obvious. It'd be something I add post-haxe output.

I updated the original post with a scrollwheel example for you. Basically you can create a javascript event listener function for damn near any event. The first parameter passed to the function (using 'e' in these examples) will be an event object. Telling that object to preventDefault will stop it from preforming it's default browser behavior.

There's a pretty extensive list of javascript events at https://developer.mozilla.org/en-US/docs/Web/Events


Arch-Angel likes this sig!

BBS Signature
LunaWolfStudios
LunaWolfStudios
  • Member since: May. 27, 2015
  • Offline.
Forum Stats
Member
Level 02
Game Developer
Response to Unity3d WebGL Support 2015-06-02 12:43:15 Reply

WebGL is not meant to actually be used right now. It creates massive flaws that completely break gameplay. Also if you're trying to use it on chrome it refuses to read arrow key inputs for some reason.

CaplJuice
CaplJuice
  • Member since: Jun. 29, 2015
  • Offline.
Forum Stats
Member
Level 04
Programmer
Response to Unity3d WebGL Support 2015-07-03 15:35:13 Reply

At 6/2/15 12:43 PM, LunaWolfStudios wrote: WebGL is not meant to actually be used right now. It creates massive flaws that completely break gameplay. Also if you're trying to use it on chrome it refuses to read arrow key inputs for some reason.

Yeah, I agree. I'm just going to stick with WebPlayer until WebGL is sorted out.


BBS Signature
D-SuN
D-SuN
  • Member since: Jan. 4, 2004
  • Offline.
Forum Stats
Supporter
Level 16
Game Developer
Response to Unity3d WebGL Support 2015-07-23 02:06:10 Reply

Our webgl game is almost working perfectly on NG. But our save data is not saving! Apparently an iFrame issue? Is there any way we can get our game to save data?

BrenTheMan
BrenTheMan
  • Member since: Sep. 8, 2006
  • Online!
Forum Stats
Member
Level 05
Blank Slate
Response to Unity3d WebGL Support 2015-07-23 14:08:01 Reply

At 7/23/15 02:06 AM, D-SuN wrote: Our webgl game is almost working perfectly on NG. But our save data is not saving! Apparently an iFrame issue? Is there any way we can get our game to save data?

Are you getting any errors in the developer console?

TenebrousP
TenebrousP
  • Member since: Oct. 26, 2013
  • Offline.
Forum Stats
Member
Level 01
Blank Slate
Response to Unity3d WebGL Support 2015-07-23 14:29:11 Reply

I struggled a bit today getting keyboard input working properly in Unity WebGL on Newgrounds, but finally have it working.

There's a couple of issues which might trip you up here.

Firstly, Unity's Input.inputString doesn't seem to work at all at the moment, so if you're using that you'll have to scan the keys using Input.GetKeyXXX.

Secondly, since NG hosts the game in an iframe, there's an issue with not having the focus set so that the game can receive key input.

You can fix this by changing index.html and adding the following to the <canvas> element:

onclick="window.focus()"

And also by adding this <script> block inside <body>:

<script>
    window.onload = function() { window.focus(); }
</script>

Hope this helps!

D-SuN
D-SuN
  • Member since: Jan. 4, 2004
  • Offline.
Forum Stats
Supporter
Level 16
Game Developer
Response to Unity3d WebGL Support 2015-07-23 22:19:06 Reply

At 7/23/15 02:08 PM, BrenTheMan wrote:
At 7/23/15 02:06 AM, D-SuN wrote: Our webgl game is almost working perfectly on NG. But our save data is not saving! Apparently an iFrame issue? Is there any way we can get our game to save data?
Are you getting any errors in the developer console?

Yup, PlayerPrefs won't be saved.

Here is a screenshot.
http://www.sun-studios.net/other/imagedump/july2015/Error.PNG

BrenTheMan
BrenTheMan
  • Member since: Sep. 8, 2006
  • Online!
Forum Stats
Member
Level 05
Blank Slate
Response to Unity3d WebGL Support 2015-07-23 22:55:46 Reply

At 7/23/15 10:19 PM, D-SuN wrote: Yup, PlayerPrefs won't be saved.

Any other info? Can you click that triangle toggle next to the warning message?

D-SuN
D-SuN
  • Member since: Jan. 4, 2004
  • Offline.
Forum Stats
Supporter
Level 16
Game Developer
Response to Unity3d WebGL Support 2015-07-24 00:17:02 Reply

At 7/23/15 10:55 PM, BrenTheMan wrote:
At 7/23/15 10:19 PM, D-SuN wrote: Yup, PlayerPrefs won't be saved.
Any other info? Can you click that triangle toggle next to the warning message?

Odly, this seems to not be an issue anymore :S
We've published out game, as the save data is now working. If I figure out why this has occured, then I'll do a post here for other to refer to.

  • Super Muzzle Flash
    Super Muzzle Flash by DimeStudios

    Warning, require Godly Twitch reaction speed

    Score
    Under Judgment
    Type
    Game
    Popularity
    6 Views
    Rated
    Everyone

HeroPower
HeroPower
  • Member since: Dec. 13, 2005
  • Offline.
Forum Stats
Member
Level 25
Game Developer
Response to Unity3d WebGL Support 2015-07-30 20:36:21 Reply

I just enabled NPAPI so that I could play Unity games on Chrome here on NG. After relaunching Chrome with this enabled if I go to a Unity game it never loads. More specifically - the window where the game should be is just completely gone... It just shows the games description and then the comment section on the webpage. Why is that?

BrenTheMan
BrenTheMan
  • Member since: Sep. 8, 2006
  • Online!
Forum Stats
Member
Level 05
Blank Slate
Response to Unity3d WebGL Support 2015-07-30 20:43:32 Reply

At 7/30/15 08:36 PM, Hero101 wrote: I just enabled NPAPI so that I could play Unity games on Chrome here on NG. After relaunching Chrome with this enabled if I go to a Unity game it never loads. More specifically - the window where the game should be is just completely gone... It just shows the games description and then the comment section on the webpage. Why is that?

This isn't the right thread for that. Post in the Help forum and make sure to link the game that you're having problems with.

Maras
Maras
  • Member since: Mar. 6, 2011
  • Offline.
Forum Stats
Member
Level 16
Game Developer
Response to Unity3d WebGL Support 2015-08-21 09:53:39 Reply

All WebGL games I have tried (including mine) still requires Unity Web Player to be loaded though... :-)

GOLDLOG
GOLDLOG
  • Member since: Sep. 28, 2015
  • Offline.
Forum Stats
Member
Level 01
Blank Slate
Response to Unity3d WebGL Support 2015-10-12 23:12:08 Reply

is templatedata necessary? the file (zip) was uploaded successfully but the preview doesn't work.
templatedata is missing in my zip but it is no need in the new version is it?

X-Shift-The-Pro-X
X-Shift-The-Pro-X
  • Member since: Jan. 29, 2015
  • Offline.
Forum Stats
Member
Level 05
Artist
Response to Unity3d WebGL Support 2015-10-13 22:24:59 Reply

I Usaully don't ask these things, But I Need to know...

So, I Made this game in unity. But I Need to know before I upload. What is better? Webplayer? Or WebGL?
I Know webGL Allows Google Chrome users to play it too, Which is why I'm leaning more towards it. But I'm worried about graphics....

What do you guys think?


Everyone is guilty of something...
But isn't there crime in punishment?

HeroPower
HeroPower
  • Member since: Dec. 13, 2005
  • Offline.
Forum Stats
Member
Level 25
Game Developer
Response to Unity3d WebGL Support 2015-10-14 01:28:24 Reply

At 10/13/15 10:24 PM, One-Eyed-Jack wrote: I Usaully don't ask these things, But I Need to know...

So, I Made this game in unity. But I Need to know before I upload. What is better? Webplayer? Or WebGL?
I Know webGL Allows Google Chrome users to play it too, Which is why I'm leaning more towards it. But I'm worried about graphics....

What do you guys think?

You can test both in the project preview before you publish it to the website

ArsalanKhan
ArsalanKhan
  • Member since: Oct. 18, 2015
  • Offline.
Forum Stats
Member
Level 01
Game Developer
Response to Unity3d WebGL Support 2015-10-21 02:11:27 Reply

Can we Use Flash ADS in WEBGYL game in Unity

HeroPower
HeroPower
  • Member since: Dec. 13, 2005
  • Offline.
Forum Stats
Member
Level 25
Game Developer
Response to Unity3d WebGL Support 2015-10-21 04:42:48 Reply

At 10/21/15 02:11 AM, ArsalanKhan wrote: Can we Use Flash ADS in WEBGYL game in Unity

No Flash Ads are for Flash games/movies...

Grenadetree
Grenadetree
  • Member since: May. 11, 2014
  • Offline.
Forum Stats
Member
Level 01
Blank Slate
Response to Unity3d WebGL Support 2015-12-06 14:51:27 Reply

Do you guys find that fewer people play or comments on games made in the webplayer / webgl on Newgrounds?


I'd love feedback on my endless runner - Just Duck It.

PsychoGoldfish
PsychoGoldfish
  • Member since: Sep. 26, 2000
  • Offline.
Forum Stats
Staff
Level 12
Programmer
Response to Unity3d WebGL Support 2015-12-07 12:43:40 Reply

At 12/6/15 02:51 PM, Grenadetree wrote: Do you guys find that fewer people play or comments on games made in the webplayer / webgl on Newgrounds?

If you look at the under judgement games ( http://www.newgrounds.com/games/under_judgment ), there's a lot of old Unity Web Player games in there that haven't even gotten enough votes to be fully included in the portal. This is primarily die to Chrome no longer supporting it. It was for that reason, we removed support for future unity web player games, opting to only support WebGL stuff. So yeah, there is definitely less people playing those unity web player games,

As for the WebGL stuff, that really seems to depend. There have been a few games made with Unity WebGL that got fairly popular, while some just haven't gained traction. I know I, personally, can't even run most WebGL games due to the insane amount of memory they require. Unity's WebGL implementation is currently very inefficient, so those games really don't work for people with lower end hardware.

I've been told they are working hard on making things better, but at this point it's really hard to even recommend using Unity for web-based content at all, when there are so many other options available.


Arch-Angel likes this sig!

BBS Signature
therealgamingturtle
therealgamingturtle
  • Member since: Jan. 4, 2016
  • Offline.
Forum Stats
Member
Level 01
Game Developer
Response to Unity3d WebGL Support 2016-01-20 12:33:26 Reply

plz help me the keys w, a, s, d. dont work. this is a huge problem because it makes my player unable to move.

JokingKitten119
JokingKitten119
  • Member since: Jan. 26, 2016
  • Offline.
Forum Stats
Member
Level 01
Blank Slate
Response to Unity3d WebGL Support 2016-01-27 12:36:33 Reply

At 5/12/15 12:04 PM, PsychoGoldfish wrote:

Having problems with your Unity3D WebGL game? Please start here. If you've read through the wiki, searched Google, etc. and still haven't resolved your issue, feel free to ask a question here.

Unity3d WebGL Support

DpnloverjordaGMD
DpnloverjordaGMD
  • Member since: Jan. 30, 2016
  • Offline.
Forum Stats
Member
Level 01
Gamer
Response to Unity3d WebGL Support 2016-02-13 02:49:32 (edited 2016-02-13 02:50:15) Reply

At 1/27/16 12:36 PM, JokingKitten119 wrote:
At 5/12/15 12:04 PM, PsychoGoldfish wrote: Having problems with your Unity3D WebGL game? Please start here. If you've read through the wiki, searched Google, etc. and still haven't resolved your issue, feel free to ask a question here.

Can you do html on the iPad mini 1?

Newground-Gaming
Newground-Gaming
  • Member since: Jan. 13, 2016
  • Offline.
Forum Stats
Member
Level 02
Blank Slate
Response to Unity3d WebGL Support 2016-02-13 13:39:53 Reply

Hey there... where do i go to get help figuring out how to get newgrounds to run .SB2 files?

Railman85
Railman85
  • Member since: Dec. 28, 2015
  • Offline.
Forum Stats
Member
Level 01
Blank Slate
Response to Unity3d WebGL Support 2016-03-08 10:32:45 Reply

Hello there!

We made game in WEBGL in unity:

  • Dogar: agar + doge
    Dogar: agar + doge by Railman85

    Select your meme and join the server! Eat other players memes to grow larger!

    Type
    Game Project

However we got this error while loading the game:
Uncaught SyntaxError: Unexpected token ILLEGAL blob:http%3A//uploads.ungrounded.net/a64b28e3-c43e-471a-affa-

Now I'm pretty much stuck, because I dont know what to do with this error
anyone got any idea?

PsychoGoldfish
PsychoGoldfish
  • Member since: Sep. 26, 2000
  • Offline.
Forum Stats
Staff
Level 12
Programmer
Response to Unity3d WebGL Support 2016-03-08 10:49:24 Reply

At 3/8/16 10:32 AM, Railman85 wrote: Hello there!

We made game in WEBGL in unity:
http://www.newgrounds.com/projects/view/934397
However we got this error while loading the game:
Uncaught SyntaxError: Unexpected token ILLEGAL blob:http%3A//uploads.ungrounded.net/a64b28e3-c43e-471a-affa-

Now I'm pretty much stuck, because I dont know what to do with this error
anyone got any idea?

Are you uploading the compressed version of the game, or the uncompressed? I *THINK* that error is related to trying to decompress a file that's not compressed, or is double compressed.


Arch-Angel likes this sig!

BBS Signature
Railman85
Railman85
  • Member since: Dec. 28, 2015
  • Offline.
Forum Stats
Member
Level 01
Blank Slate
Response to Unity3d WebGL Support 2016-03-08 15:22:39 Reply

At 3/8/16 10:49 AM, PsychoGoldfish wrote:
At 3/8/16 10:32 AM, Railman85 wrote: Hello there!

We made game in WEBGL in unity:
http://www.newgrounds.com/projects/view/934397
However we got this error while loading the game:
Uncaught SyntaxError: Unexpected token ILLEGAL blob:http%3A//uploads.ungrounded.net/a64b28e3-c43e-471a-affa-

Now I'm pretty much stuck, because I dont know what to do with this error
anyone got any idea?
Are you uploading the compressed version of the game, or the uncompressed? I *THINK* that error is related to trying to decompress a file that's not compressed, or is double compressed.

thank you for your answer.
Starting with Unity 5.3 unity WEBGL files are compressed now by default. (they dont put .htacces files anymore).

I just got files:
dogar.datagz
dogar.jsgz
dogar.memgz
UnityLoader.js
All compressed.

You are right, that sound like some problem with compression - got any hint what to do next/what to read?

PsychoGoldfish
PsychoGoldfish
  • Member since: Sep. 26, 2000
  • Offline.
Forum Stats
Staff
Level 12
Programmer
Response to Unity3d WebGL Support 2016-03-08 17:16:49 Reply

At 3/8/16 03:22 PM, Railman85 wrote:
At 3/8/16 10:49 AM, PsychoGoldfish wrote:
At 3/8/16 10:32 AM, Railman85 wrote: Hello there!

We made game in WEBGL in unity:
http://www.newgrounds.com/projects/view/934397
However we got this error while loading the game:
Uncaught SyntaxError: Unexpected token ILLEGAL blob:http%3A//uploads.ungrounded.net/a64b28e3-c43e-471a-affa-

Now I'm pretty much stuck, because I dont know what to do with this error
anyone got any idea?
Are you uploading the compressed version of the game, or the uncompressed? I *THINK* that error is related to trying to decompress a file that's not compressed, or is double compressed.
thank you for your answer.
Starting with Unity 5.3 unity WEBGL files are compressed now by default. (they dont put .htacces files anymore).

I just got files:
dogar.datagz
dogar.jsgz
dogar.memgz
UnityLoader.js
All compressed.

You are right, that sound like some problem with compression - got any hint what to do next/what to read?

It should also make un-compressed files. Try using those instead. When you put them in a zip, they get compressed for upload, and our servers should be serving them automatically compressed (without needing a .htaccess file).


Arch-Angel likes this sig!

BBS Signature
Railman85
Railman85
  • Member since: Dec. 28, 2015
  • Offline.
Forum Stats
Member
Level 01
Blank Slate
Response to Unity3d WebGL Support 2016-03-09 09:11:37 Reply

It should also make un-compressed files. Try using those instead. When you put them in a zip, they get compressed for upload, and our servers should be serving them automatically compressed (without needing a .htaccess file).

thank you for your help.

For those who have this problem:
You can simply unzip your:
dogar.datagz
dogar.jsgz
dogar.memgz

into

dogar.data
dogar.js
dogar.mem

and it will work like a charm :)