Hello. I want to be able to alter the URL while the Unity WebGL App is running.
The Url changes but unfortunatly the WebGL App restarts as soon as i do this.
Is this a bug or am i doing something wrong?
I do it via a *.jslib file in a “Plugins” folder with the content:
mergeInto(LibraryManager.library, {
SetParam: function(param){
window.location.search = "/" + Pointer_stringify(param);
}
});
Then in C# i import the function and use it like this:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Runtime.InteropServices;
public class changeUrl : MonoBehaviour
{
//import javascript library functions
[DllImport("__Internal")]
private static extern void SetParam(string param);
public string nameOFUrl;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
public void changeUrlOnClick()
{
Debug.Log("switching to: " + nameOFUrl);
SetParam(nameOFUrl);
}
}