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 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)); } } }