Requirements of such clients developed with WEBGL but the landing interface is a normal HTML page
For example, you go to the Unity WebGL page after landing Baidu
Because of the stateless and non-connected nature of HTTP, we need to use the address bar to pass the login information to the game interface.
Customary code (Drip drive)
?
1234567 |
[DllImport(
"__Internal"
)]
private static extern string StringReturnValueFunction();
public static string UrlMsg=
string
.Empty;
void Start()
{
UrlMsg = StringReturnValueFunction();
}
|
The code is simple, but because the light has code, it needs to be dropped (see picture) <ignore_js_op>
so.png (8.99 KB, download number: 1)
Download attachments to albums
I'm a figure.
Uploaded 4 days ago
Well, we need to write a jslib file ourselves (this file will be added to the unity-generated JS when the build is built)
Code content
?
0102030405060708091011 |
var MyPlugin = {
StringReturnValueFunction:
function
()
{
var returnStr = window.location.search;
var buffer = _malloc(lengthBytesUTF8(returnStr) + 1);
writeStringToMemory(returnStr, buffer);
return buffer;
}
};
mergeInto(LibraryManager.library, MyPlugin);
|
Remember that the file format is Jslib
All right, knock it off.
This allows you to jump from Baidu to the published WebGL interface to get the URL content of the current page
Unity WebGL Gets the URL information for the jump page