I’m seeing a strange thing with my WebGL project in 5.1 that i haven’t seen with any 5.0x builds.
If i host the game on my localhost with xampp i don’t seem to get the problem unless i’m loading it through https. (which had no problems yesterday on 5.1.0f2).
Without any exceptions turned on, i just get an error “Script Error”. So i turn on exceptions, and then i get a bit more detail. “console.logError is not a function”.
So i opened up the .js file for my game and looked for console.logError, and there it was, just one reference.
i changed it to console.log instead of logError and that fixed it.
The code that’s generated looks like this… (i’ve formatted it to make it easier to read)
function _JS_Cursor_SetCursorString(cursor)
{
try
{
if(document.styleSheets.length==0)
{
console.log("can't set cursor because there is no style sheet.");
return
}
var styleSheet=document.styleSheets[0];
var rule="canvas.emscripten { border: 0px none; cursor: "+cursor+"; }";
for(var i=0; i<styleSheet.cssRules.length; i++)
{
if(styleSheet.cssRules[i].cssText.indexOf("canvas.emscripten")!=-1)
{
styleSheet.deleteRule(i);
styleSheet.insertRule(rule,0);
return
}
}
styleSheet.insertRule(rule,0)
}catch(e)
{
console.logError("Could not set cursor due to exception "+e)
}
}
is this a problem with emscripten? or something new in 5.1?
I’m not doing anything with the Cursor in my project anywhere.
Don’t know why this occurs but a quick fix without having to do string-replace for each export is to just add this line to any javascript in your page:
console.logError = console.log;
ya, i was able to fix it even just by doing a find and replace but that’s not a very good solution since our build pipeline is automated and wouldn’t support that.
Yeah, thats why I think my suggestion is at least slightly better. Even with an automated build pipeline you could have a WebplayerTemplate or just html-file that you don’t rebuild every time, that has this little snippet:
Then you could use your automated build pipeline without the need for find&replace.
Thanks for reporting this, it will be fixed in 5.2. The workaround should work for now.
Though, I don’t know why this would have worked for you before. The issue is that you’d get an exception here because you have css styles from a different domain, which cannot be accessed due to CORS restrictions. When trying to set the cursor, Unity would iterate over these and throw a security exception - we did not catch that exception in 5.0.
Will the cursor setting be fixed in 5.2 as well? It seems to me that developers using style sheets from a different domain will be a common occurrence.