public static void ConnectionTargetSelectionDropdown(Rect rect, IConnectionState state, GUIStyle style = null) { var internalState = state as IConnectionStateInternal; if (internalState?.parentWindow) { if (internalState.notificationMessage != null) { internalState.parentWindow.ShowNotification(internalState.notificationMessage); } else { internalState.parentWindow.RemoveNotification(); } } style ??= Styles.defaultDropdown; if (!UnityEditor.EditorGUI.DropdownButton(rect, Styles.dropdownButton, FocusType.Keyboard, style)) { return; } if (internalState != null) { ConnectionTreeViewWindow ctvw = new ConnectionTreeViewWindow(internalState, rect); PopupWindow.Show(rect, ctvw); } }
void AddConnectionViaEnterIPWindow(ConnectionTreeViewWindow menuOptions, Rect buttonScreenRect, Func <bool> disabler = null) { menuOptions.AddItem(new ConnectionDropDownItem(Content.EnterIPText.text, -2, Content.DirectConnection, ConnectionDropDownItem.ConnectionMajorGroup.Direct, () => false, () => { AttachToPlayerPlayerIPWindow.Show(buttonScreenRect); GUIUtility.ExitGUI(); // clear the gui state to prevent hot control issues })); }
void AddLastConnectedIP(ConnectionTreeViewWindow menuOptions, ref bool hasOpenConnection) { string lastIP = AttachToPlayerPlayerIPWindow.GetLastIPString(); if (string.IsNullOrEmpty(lastIP)) { return; } bool isConnected = ProfilerDriver.connectedProfiler == PLAYER_DIRECT_IP_CONNECT_GUID; hasOpenConnection |= isConnected; menuOptions.AddItem(new ConnectionDropDownItem(lastIP, PLAYER_DIRECT_IP_CONNECT_GUID, Content.DirectConnection, ConnectionDropDownItem.ConnectionMajorGroup.Direct, () => ProfilerDriver.connectedProfiler == PLAYER_DIRECT_IP_CONNECT_GUID, () => DirectIPConnect(lastIP))); }
public virtual void AddItemsToTree(ConnectionTreeViewWindow menu, Rect position) { bool hasAnyConnectionOpen = false; AddAvailablePlayerConnections(menu, ref hasAnyConnectionOpen); AddAvailableDeviceConnections(menu, ref hasAnyConnectionOpen); AddLastConnectedIP(menu, ref hasAnyConnectionOpen); // Case 810030: Check if player is connected using AutoConnect Profiler feature via 'connect <ip> string in PlayerConnectionConfigFile // In that case ProfilerDriver.GetAvailableProfilers() won't return the connected player // But we still want to show that it's connected, because the data is incoming if (!ProfilerDriver.IsConnectionEditor() && !hasAnyConnectionOpen) { menu.AddDisabledItem(new ConnectionDropDownItem(Content.AutoconnectedPlayer.text, ProfilerDriver.connectedProfiler, Content.DirectConnection, ConnectionDropDownItem.ConnectionMajorGroup.Direct, () => true, null)); } AddConnectionViaEnterIPWindow(menu, GUIUtility.GUIToScreenRect(position)); }
void AddAvailableDeviceConnections(ConnectionTreeViewWindow menuOptions, ref bool hasOpenConnection) { foreach (var device in DevDeviceList.GetDevices()) { bool supportsPlayerConnection = (device.features & DevDeviceFeatures.PlayerConnection) != 0; if (!device.isConnected || !supportsPlayerConnection) { continue; } var url = "device://" + device.id; bool isConnected = ProfilerDriver.connectedProfiler == PLAYER_DIRECT_URL_CONNECT_GUID && ProfilerDriver.directConnectionUrl == url; hasOpenConnection |= isConnected; //iphone handles the naming differently to android menuOptions.AddItem(new ConnectionDropDownItem( device.type == "Android" ? device.name.Substring(device.name.IndexOf('(') + 1).TrimEnd(')') : device.name, PLAYER_DIRECT_URL_CONNECT_GUID, "Devices", ConnectionDropDownItem.ConnectionMajorGroup.Local, () => ProfilerDriver.connectedProfiler == PLAYER_DIRECT_URL_CONNECT_GUID && ProfilerDriver.directConnectionUrl == url, () => DirectURLConnect(url), true, device.type == "iOS" ? "IPhonePlayer" : device.type)); } }
void AddAvailablePlayerConnections(ConnectionTreeViewWindow menuOptions, ref bool hasOpenConnection, Func <bool> disabler = null) { int[] connectionGuids = ProfilerDriver.GetAvailableProfilers(); for (int index = 0; index < connectionGuids.Length; index++) { int guid = connectionGuids[index]; string name = GetConnectionName(guid); bool isProhibited = ProfilerDriver.IsIdentifierOnLocalhost(guid) && (name.Contains("MetroPlayerX") || name.Contains("UWPPlayerX")); bool enabled = !isProhibited && ProfilerDriver.IsIdentifierConnectable(guid); bool isConnected = ProfilerDriver.connectedProfiler == guid; hasOpenConnection |= isConnected; if (!enabled) { if (isProhibited) { name += Content.LocalHostProhibited; } else { name += Content.VersionMismatch; } } if (enabled) { if (m_EditorModeTargetState.HasValue && name.Contains(k_EditorConnectionName)) { if (!menuOptions.HasItem(Content.Playmode.text) && !name.StartsWith("Profiler-")) { menuOptions.AddItem(new ConnectionDropDownItem(Content.Playmode.text, guid, Content.Editor, ConnectionDropDownItem.ConnectionMajorGroup.Editor, () => ProfilerDriver.connectedProfiler == guid && !m_EditorModeTargetConnectionStatus(EditorConnectionTarget .MainEditorProcessPlaymode), () => { ProfilerDriver.connectedProfiler = guid; SuccessfullyConnectedToPlayer(connectionName, EditorConnectionTarget.MainEditorProcessPlaymode); })); menuOptions.AddItem(new ConnectionDropDownItem(Content.Editmode.text, guid, Content.Editor, ConnectionDropDownItem.ConnectionMajorGroup.Editor, () => ProfilerDriver.connectedProfiler == guid && m_EditorModeTargetConnectionStatus(EditorConnectionTarget .MainEditorProcessEditmode), () => { ProfilerDriver.connectedProfiler = guid; SuccessfullyConnectedToPlayer(connectionName, EditorConnectionTarget.MainEditorProcessEditmode); })); } } else { menuOptions.AddItem(new ConnectionDropDownItem( name, guid, null, ConnectionDropDownItem.ConnectionMajorGroup.Unknown, () => ProfilerDriver.connectedProfiler == guid, () => { ProfilerDriver.connectedProfiler = guid; if (ProfilerDriver.connectedProfiler == guid) { SuccessfullyConnectedToPlayer(connectionName); } })); } } else { menuOptions.AddDisabledItem(new ConnectionDropDownItem(name, guid, null, ConnectionDropDownItem.ConnectionMajorGroup.Unknown, () => ProfilerDriver.connectedProfiler == guid, null)); } } }
public override void AddItemsToTree(ConnectionTreeViewWindow view, Rect position) { view.SetLoggingOptions(this); base.AddItemsToTree(view, position); }