0 votes
by (120 points)

建议PicoXR SDK 新增Network adb支持
建议PicoXR SDK 新增Network adb支持
建议PicoXR SDK 新增Network adb支持
enter image description here

大致实现方式:

private string connectIP = "Please Input Device's IP and ADB Port";
private void OnGUI(){
    ...
    GUILayout.Space(10.0f);
    GUILayout.Label("Device Network Connect", EditorStyles.boldLabel);

    EditorGUILayout.BeginHorizontal();
    {
        GUIContent u2nBtn = new GUIContent("USB adb to TCP adb");
        var u2nBtnRect = GUILayoutUtility.GetRect(u2nBtn, GUI.skin.textField, GUILayout.Width(200));
        if (GUI.Button(u2nBtnRect, u2nBtn)) {
            if (PXR_ADBTool.GetInstance().IsReady()) {
                string outlog, outerror;
                PXR_ADBTool.GetInstance().RunCommand(new string[] { "exec-out", "ifconfig","wlan0" }, null, out outlog, out outerror);
                Regex regex = new Regex("inet addr:([^ ]*)");
                Match m = regex.Match(outlog);
                if (m.Groups.Count == 2)
                {
                    connectIP = m.Groups[1].Value;
                }
                PXR_ADBTool.GetInstance().RunCommand(new string[] { "tcpip", "5555" }, null, out outlog, out outerror);
            }
            else
            {
                PrintLog("Adb is Not Ready!", LogType.Error);
            }
        }
        GUIContent connectBtn = new GUIContent("Connect");
        var connectRect = GUILayoutUtility.GetRect(connectBtn, GUI.skin.textField, GUILayout.Width(200));
        connectIP = GUI.TextField(connectRect, connectIP);
        var connectBtnRect = GUILayoutUtility.GetRect(connectBtn, GUI.skin.button, GUILayout.Width(200));
        if (GUI.Button(connectBtnRect, connectBtn)) {
            if (PXR_ADBTool.GetInstance().IsReady())
            {
                string outlog, outerror;
                PXR_ADBTool.GetInstance().RunCommand(new string[] { "connect", connectIP }, null, out outlog, out outerror);
                PrintLog(outlog, LogType.Normal);
            }
            else
            {
                PrintLog("Adb is Not Ready!", LogType.Error);
            }
        }
    }
    EditorGUILayout.EndHorizontal();
    ...
}

1 Answer

0 votes
by (55.5k points)

开发者您好,
十分感谢您的积极反馈与建议。

...