private void DisplayPortForwarding() { _foldOutScenes = UnityEditor.EditorGUILayout.Foldout(_foldOutScenes, "PortForwading"); UnityEditor.EditorGUILayout.BeginHorizontal(); UnityEditor.EditorGUILayout.LabelField("", UnityEngine.GUILayout.MaxWidth(30)); UnityEditor.EditorGUILayout.BeginVertical(); if (_foldOutScenes) { UnityEngine.GUILayout.BeginVertical(UnityEngine.GUI.skin.textField); UnityEngine.GUILayout.BeginHorizontal(); UnityEngine.GUILayout.Label("DeviceId", UnityEditor.EditorStyles.boldLabel, UnityEngine.GUILayout.MinWidth(50)); UnityEngine.GUILayout.Label("Local Port", UnityEditor.EditorStyles.boldLabel, UnityEngine.GUILayout.MinWidth(50), UnityEngine.GUILayout.MaxWidth(100)); UnityEngine.GUILayout.Label("Remote Port", UnityEditor.EditorStyles.boldLabel, UnityEngine.GUILayout.MinWidth(50), UnityEngine.GUILayout.MaxWidth(100)); if (UnityEngine.GUILayout.Button("Refresh", UnityEngine.GUILayout.MinWidth(50), UnityEngine.GUILayout.MaxWidth(100))) { RefreshDeviceList(); } UnityEngine.GUILayout.EndHorizontal(); if (devices.Count != 0) { foreach (var device in devices) { if (device.Active) { var styleActive = new UnityEngine.GUIStyle(UnityEngine.GUI.skin.textField); styleActive.normal.background = MakeTexture(20, 20, greenColor); UnityEngine.GUILayout.BeginHorizontal(styleActive); UnityEngine.GUILayout.Label(device.DeviceId, UnityEngine.GUILayout.MinWidth(50)); UnityEngine.GUILayout.Label(device.LocalPort.ToString(), UnityEngine.GUILayout.MinWidth(50), UnityEngine.GUILayout.MaxWidth(100)); UnityEngine.GUILayout.Label(device.RemotePort.ToString(), UnityEngine.GUILayout.MinWidth(50), UnityEngine.GUILayout.MaxWidth(100)); if (UnityEngine.GUILayout.Button("Stop", UnityEngine.GUILayout.MinWidth(50), UnityEngine.GUILayout.MaxWidth(100))) { if (device.Platform == Platform.Android) { AltUnityPortHandler.RemoveForwardAndroid(device.LocalPort, device.DeviceId); } #if UNITY_EDITOR_OSX else { int id; if (iosForwards.TryGetValue(device.DeviceId, out id)) { AltUnityPortHandler.KillIProxy(id); iosForwards.Remove(device.DeviceId); } } #endif device.Active = false; RefreshDeviceList(); } } else { var style = UnityEngine.GUI.skin.textField; UnityEngine.GUILayout.BeginHorizontal(style); UnityEngine.GUILayout.Label(device.DeviceId, UnityEngine.GUILayout.MinWidth(50)); device.LocalPort = UnityEditor.EditorGUILayout.IntField(device.LocalPort, UnityEngine.GUILayout.MinWidth(50), UnityEngine.GUILayout.MaxWidth(100)); device.RemotePort = UnityEditor.EditorGUILayout.IntField(device.RemotePort, UnityEngine.GUILayout.MinWidth(50), UnityEngine.GUILayout.MaxWidth(100)); if (UnityEngine.GUILayout.Button("Start", UnityEngine.GUILayout.MinWidth(50), UnityEngine.GUILayout.MaxWidth(100))) { if (device.Platform == Platform.Android) { var response = AltUnityPortHandler.ForwardAndroid(device.DeviceId, device.LocalPort, device.RemotePort); if (!response.Equals("Ok")) { UnityEngine.Debug.LogError(response); } } #if UNITY_EDITOR_OSX else { var response = AltUnityPortHandler.ForwardIos(device.DeviceId, device.LocalPort, device.RemotePort); if (response.StartsWith("Ok")) { var processID = int.Parse(response.Split(' ')[1]); iosForwards.Add(device.DeviceId, processID); device.Active = true; } else { UnityEngine.Debug.LogError(response); } } #endif RefreshDeviceList(); } } UnityEngine.GUILayout.EndHorizontal(); } } else { UnityEditor.EditorGUILayout.TextArea("No devices connected. Click \"refresh\" button to search for devices"); } UnityEngine.GUILayout.EndVertical(); } UnityEditor.EditorGUILayout.EndVertical(); UnityEditor.EditorGUILayout.EndHorizontal(); }