1. Registry configuration
This part is reproduced from https://www.bbsmax.com/A/rV57pg4VdP/
1.1 Use Notepad (or other text editor) to create a protocol.reg file and write the following content
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Webshell]
@="URL:Webshell Protocol Handler"
"URL Protocol"=""
[HKEY_CLASSES_ROOT\Webshell\DefaultIcon]
@="C:\\Program Files (x86)\\Tencent\\WeChat\\WeChat.exe"
[HKEY_CLASSES_ROOT\Webshell\shell]
[HKEY_CLASSES_ROOT\Webshell\shell\open]
[HKEY_CLASSES_ROOT\Webshell\shell\open\command]
@="\"C:\\Program Files (x86)\\Tencent\\WeChat\\WeChat.exe\" \"%1\""
1.2 Modify parameters
After opening the file with Notepad, modify the relevant parameters according to the instructions in the figure below
1.2.1 Modify the connection name
Modify the name in the red box to customize, all use English characters (the name is the href when calling), a total of six
1.2.2 modify the path of the executable file
Modify the path of the executable file in the red box, there are two places
Note: use // split
1.2.3 in the file path to execute the protocol.reg file
2.js file
Create a call
connection The connection address is the name of the link named in step 1, followed by ://type=1, (type=1 is a transfer parameter, which can be added arbitrarily)
3. Unity settings
Create a new scene and write the following script
using System.Collections.Generic;
using UnityEngine;
using System;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class ReceiveParameter : MonoBehaviour
{
public Text Text;
private void Start()
{
List<string> commandLineArgs = new List<string>(Environment.GetCommandLineArgs());
//取索引为>=1的部分 index=0的值为文件路径信息
string data = commandLineArgs[1];
Text.text = data;
}
}
Hang in the scene and drag into a text box