Unity WebGL Gets the URL information for the jump page

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.