mirror of
https://github.com/codeninjasuk/game-codey-chef.git
synced 2025-07-03 10:50:20 -04:00
1 line
16 KiB
JavaScript
1 line
16 KiB
JavaScript
|
function createUnityInstance(t,n,d){function i(e,r){if(!i.aborted&&n.showBanner)return"error"==r&&(i.aborted=!0),n.showBanner(e,r);switch(r){case"error":console.error(e);break;case"warning":console.warn(e);break;default:console.log(e)}}function o(e){var r=e.reason||e.error,t=r?r.toString():e.message||e.reason||"",n=r&&r.stack?r.stack.toString():"";(t+="\n"+(n=n.startsWith(t)?n.substring(t.length):n).trim())&&c.stackTraceRegExp&&c.stackTraceRegExp.test(t)&&f(t,e.filename||r&&(r.fileName||r.sourceURL)||"",e.lineno||r&&(r.lineNumber||r.line)||0)}function e(e,r,t){var n=e[r];void 0!==n&&n||(console.warn('Config option "'+r+'" is missing or empty. Falling back to default value: "'+t+'". Consider updating your WebGL template to include the missing config option.'),e[r]=t)}d=d||function(){};var r,c={canvas:t,webglContextAttributes:{preserveDrawingBuffer:!1},cacheControl:function(e){return e==c.dataUrl?"must-revalidate":"no-store"},streamingAssetsUrl:"StreamingAssets",downloadProgress:{},deinitializers:[],intervals:{},setInterval:function(e,r){e=window.setInterval(e,r);return this.intervals[e]=!0,e},clearInterval:function(e){delete this.intervals[e],window.clearInterval(e)},preRun:[],postRun:[],print:function(e){console.log(e)},printErr:function(e){console.error(e),"string"==typeof e&&-1!=e.indexOf("wasm streaming compile failed")&&(-1!=e.toLowerCase().indexOf("mime")?i('HTTP Response Header "Content-Type" configured incorrectly on the server for file '+c.codeUrl+' , should be "application/wasm". Startup time performance will suffer.',"warning"):i('WebAssembly streaming compilation failed! This can happen for example if "Content-Encoding" HTTP header is incorrectly enabled on the server for file '+c.codeUrl+", but the file is not pre-compressed on disk (or vice versa). Check the Network tab in browser Devtools to debug server header configuration.","warning"))},locateFile:function(e){return"build.wasm"==e?this.codeUrl:e},disabledCanvasEvents:["contextmenu","dragstart"]};for(r in e(n,"companyName","Unity"),e(n,"productName","WebGL Player"),e(n,"productVersion","1.0"),n)c[r]=n[r];c.streamingAssetsUrl=new URL(c.streamingAssetsUrl,document.URL).href;var a=c.disabledCanvasEvents.slice();function s(e){e.preventDefault()}a.forEach(function(e){t.addEventListener(e,s)}),window.addEventListener("error",o),window.addEventListener("unhandledrejection",o);var l="",u="",h=(document.addEventListener("webkitfullscreenchange",function(e){document.webkitCurrentFullScreenElement===t?t.style.width&&(l=t.style.width,u=t.style.height,t.style.width="100%",t.style.height="100%"):l&&(t.style.width=l,t.style.height=u,u=l="")}),{Module:c,SetFullscreen:function(){if(c.SetFullscreen)return c.SetFullscreen.apply(c,arguments);c.print("Failed to set Fullscreen mode: Player not loaded yet.")},SendMessage:function(){if(c.SendMessage)return c.SendMessage.apply(c,arguments);c.print("Failed to execute SendMessage: Player not loaded yet.")},Quit:function(){return new Promise(function(e,r){c.shouldQuit=!0,c.onQuit=e,a.forEach(function(e){t.removeEventListener(e,s)}),window.removeEventListener("error",o),window.removeEventListener("unhandledrejection",o)})}});function f(e,r,t){c.startupErrorHandler?c.startupErrorHandler(e,r,t):c.errorHandler&&c.errorHandler(e,r,t)||(console.log("Invoking error handler due to\n"+e),"function"==typeof dump&&dump("Invoking error handler due to\n"+e),-1!=e.indexOf("UnknownError")||-1!=e.indexOf("Program terminated with exit(0)")||f.didShowErrorMessage||(-1!=(e="An error occurred running the Unity content on this page. See your browser JavaScript console for more info. The error was:\n"+e).indexOf("DISABLE_EXCEPTION_CATCHING")?e="An exception has occurred, but exception handling has been disabled in this build. If you are the developer of this content, enable exceptions in your project WebGL player settings to be able to catch the exception or see the stack trace.":-1!=e.indexOf("Cannot enlarge memory arrays")?e="Out of memory. If you are the developer of this content, try allocating more memory to your WebGL build in the WebGL player set
|