您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
41 行
1.0 KiB
41 行
1.0 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using Unity.MegaCity.Gameplay;
|
|
using UnityEngine.Events;
|
|
using Random = UnityEngine.Random;
|
|
|
|
namespace Unity.MegaCity.UI
|
|
{
|
|
public class IPConnectorPanelController : MonoBehaviour
|
|
{
|
|
// 根据 ip:port 连接服务器
|
|
public InputField ipInput;
|
|
private MultiverseRoomAPI _lobbyInstance;
|
|
|
|
void Start()
|
|
{
|
|
_lobbyInstance = MultiverseRoomAPI.Instance;
|
|
}
|
|
|
|
public void ConnectByIPAndPort()
|
|
{
|
|
if (ipInput.text == "")
|
|
{
|
|
return;
|
|
}
|
|
|
|
MainMenu.Instance.ShowLoading();
|
|
try
|
|
{
|
|
_lobbyInstance.ConnectByIP(ipInput.text);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
UIMessage.Instance.Show("Failed to connect to the server. Please try again.");
|
|
MainMenu.Instance.HideLoading();
|
|
}
|
|
}
|
|
}
|
|
}
|