Example #1
0
        protected override void OnAttachToProcess(long processId)
        {
            if (connectorRegistry.Connectors.ContainsKey((uint)processId))
            {
                currentConnector = connectorRegistry.Connectors[(uint)processId];
                StartConnecting(currentConnector.SetupConnection(), 3, 1000);
                return;
            }
            else if (UnitySoftDebuggerEngine.UnityPlayers.ContainsKey((uint)processId))
            {
                PlayerConnection.PlayerInfo player = UnitySoftDebuggerEngine.UnityPlayers[(uint)processId];
                int port = (0 == player.m_DebuggerPort
                                        ? (int)(56000 + (processId % 1000))
                                        : (int)player.m_DebuggerPort);
                try {
                    StartConnecting(new SoftDebuggerStartInfo(new SoftDebuggerConnectArgs(player.m_Id, player.m_IPEndPoint.Address, (int)port)), 3, 1000);
                } catch (Exception ex) {
                    throw new Exception(string.Format("Unable to attach to {0}:{1}", player.m_IPEndPoint.Address, port), ex);
                }
                return;
            }

            long defaultPort = 56000 + (processId % 1000);

            StartConnecting(new SoftDebuggerStartInfo(new SoftDebuggerConnectArgs(null, IPAddress.Loopback, (int)defaultPort)), 3, 1000);
        }
        public static UnityAttachInfo GetUnityAttachInfo(long processId, ref IUnityDbgConnector connector)
        {
            if (ConnectorRegistry.Connectors.ContainsKey((uint)processId))
            {
                connector = ConnectorRegistry.Connectors[(uint)processId];
                return(connector.SetupConnection());
            }
            else if (UnityPlayers.ContainsKey((uint)processId))
            {
                PlayerConnection.PlayerInfo player = UnityPlayers[(uint)processId];
                int port = 0 == player.m_DebuggerPort
                    ? (int)(56000 + processId % 1000)
                    : (int)player.m_DebuggerPort;
                try
                {
                    return(new UnityAttachInfo(player.m_Id, player.m_IPEndPoint.Address, port));
                }
                catch (Exception ex)
                {
                    throw new Exception($"Unable to attach to {player.m_IPEndPoint.Address}:{port}", ex);
                }
            }

            long defaultPort = 56000 + (processId % 1000);

            return(new UnityAttachInfo(null, IPAddress.Loopback, (int)defaultPort));
        }
		protected override void OnAttachToProcess (long processId)
		{
			if (connectorRegistry.Connectors.ContainsKey((uint)processId)) {
				currentConnector = connectorRegistry.Connectors[(uint)processId];
				StartConnecting(currentConnector.SetupConnection(), 3, 1000);
				return;
			} else if (UnitySoftDebuggerEngine.UnityPlayers.ContainsKey ((uint)processId)) {
				PlayerConnection.PlayerInfo player = UnitySoftDebuggerEngine.UnityPlayers[(uint)processId];
				int port = (0 == player.m_DebuggerPort
					? (int)(56000 + (processId % 1000))
					: (int)player.m_DebuggerPort);
				try {
					StartConnecting (new SoftDebuggerStartInfo (new SoftDebuggerConnectArgs (player.m_Id, player.m_IPEndPoint.Address, (int)port)), 3, 1000);
				} catch (Exception ex) {
					throw new Exception (string.Format ("Unable to attach to {0}:{1}", player.m_IPEndPoint.Address, port), ex);
				}
				return;
			}
			base.OnAttachToProcess (processId);
		}