- Home /
WebGL - InvalidStateError: An attempt was made to use an object that is not, or is no longer, usable
Hi there,
I want to change the url in the browser, according to several buttonNames, once the buttons are pressed.
I try to change the url via javascript with this javascriptlibrary.
QueryHandler.jslib
var QueryHandler = {
GetParam: function(){
var level = "";
var queryString = window.location.search.substring(1);
var params = queryString.split("&");
for (var i=0; i<params.length; i++) {
var param = params[i].split("=");
if(param[0] == "level"){ level = param[1]; }
}
//send string to Unity
var buffer = _malloc(lengthBytesUTF8(level) + 1);
writeStringToMemory(level, buffer);
return buffer;
},
SetParam: function(param){
console.log("window.location.search");
window.location.search = "?level=" + Pointer_stringify(param);
}
};
mergeInto(LibraryManager.library, QueryHandler);
On the buttons i have this C# script
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using System.Runtime.InteropServices;
public class Url_manipulator : MonoBehaviour
{
[DllImport("__Internal")]
private static extern string GetParam();
[DllImport("__Internal")]
private static extern void SetParam(string str);
public string path;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
private void OnMouseDown()
{
SetParam(path);
}
}
It changes the Url perfectly fine, but the project unfortunatly restarts, so i see the loading screen and everything.
Also theres InvalidStateError in the mozilla console (same behaviour on chrome):
InvalidStateError: An attempt was made to use an object that is not, or is no longer, usable
The script from “http://localhost:59540/TemplateData/UnityProgress.javascript” was loaded even though its MIME type (“”) is not a valid JavaScript MIME type.[Learn More] localhost:59540
The script from “http://localhost:59540/Build/UnityLoader.js” was loaded even though its MIME type (“”) is not a valid JavaScript MIME type.[Learn More] localhost:59540
Successfully compiled asm.js code (total compilation time 0ms)
UnityLoader.js
The script from “http://localhost:59540/TemplateData/responsive.javascript” was loaded even though its MIME type (“”) is not a valid JavaScript MIME type.[Learn More] localhost:59540
Responsive WebGL Template by SIMMER.io v2019.02.08 responsive.javascript:2:5
Available at: https://assetstore.unity.com/packages/tools/gui/responsive-webgl-template-117308 for free! responsive.javascript:3:5
Host your WebGL Game at SIMMER.io for free! responsive.javascript:4:5
You can reduce your startup time if you configure your web server to host .unityweb files using gzip compression. UnityLoader.js:3:8480
[UnityCache] 'http://localhost:59540/Build/unity%20test.wasm.framework.unityweb' successfully downloaded and stored in the indexedDB cache UnityLoader.js:4:11214
[UnityCache] 'http://localhost:59540/Build/unity%20test.wasm.code.unityweb' successfully downloaded and stored in the indexedDB cache UnityLoader.js:4:11214
[UnityCache] 'http://localhost:59540/Build/unity%20test.data.unityweb' successfully downloaded and stored in the indexedDB cache UnityLoader.js:4:11214
Loading player data from data.unity3d UnityLoader.js:4:9380
Initialize engine version: 2018.3.9f1 (947e1ea5aa8d) UnityLoader.js:4:9380
Creating WebGL 2.0 context. UnityLoader.js:4:9380
Renderer: Mozilla UnityLoader.js:4:9380
Vendor: Mozilla UnityLoader.js:4:9380
Version: OpenGL ES 3.0 (WebGL 2.0) UnityLoader.js:4:9380
GLES: 3 UnityLoader.js:4:9380
EXT_color_buffer_float GL_EXT_color_buffer_float EXT_texture_filter_anisotropic GL_EXT_texture_filter_anisotropic OES_texture_float_linear GL_OES_texture_float_linear WEBGL_compressed_texture_s3tc GL_WEBGL_compressed_texture_s3tc WEBGL_compressed_texture_s3tc_srgb GL_WEBGL_compressed_texture_s3tc_srgb WEBGL_debug_renderer_info GL_WEBGL_debug_renderer_info WEBGL_debug_shaders GL_WEBGL_debug_shaders WEBGL_lose_context GL_WEBGL_lose_context UnityLoader.js:4:9380
OPENGL LOG: Creating OpenGL ES 3.0 graphics device ; Context level <OpenGL ES 3.0> ; Context handle 1 UnityLoader.js:4:9380
WARNING: Shader Unsupported: 'Standard' - Pass 'META' has no vertex shader
UnityLoader.js:4:9380
UnloadTime: 0.000000 ms UnityLoader.js:4:9380
Use of the motion sensor is deprecated. 9d80b04b-1533-48a2-9bd1-f8f333642324:2:228360
Use of the orientation sensor is deprecated. 9d80b04b-1533-48a2-9bd1-f8f333642324:2:228360
Maybe someone is realy into this topic and help me ?! :)
Answer by David062 · May 29, 2019 at 09:05 AM
Which means that you can make iterables that are lazy. Calling the built-in next function on an object will attempt to call its next method prepaidgiftbalance.
Your answer
Follow this Question
Related Questions
How to read URL parameters from Unity WebGL Build 4 Answers
Mute audio in webgl outside of the player. 0 Answers
Webgl : How to use javascript sharing function 0 Answers
Can someone help me fix my Javascript for Flickering Light? 6 Answers
How to get the game data to the Web (webgl or webplayer) 1 Answer