56 lines
1.4 KiB
C#
56 lines
1.4 KiB
C#
using Assets.Scripts;
|
|
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
using UnityEngine.UI;
|
|
|
|
class GameRoomPassword : MonoBehaviour
|
|
{
|
|
public GameObject enterBtn;
|
|
public GameObject backBtn;
|
|
public InputField passwordInput;
|
|
|
|
public GameRoomListController manager;
|
|
|
|
public string Password { get; set; }
|
|
|
|
private void Start()
|
|
{
|
|
passwordInput.onValueChanged.AddListener((e) =>
|
|
{
|
|
Password = e;
|
|
});
|
|
UIManager.AddEvent(enterBtn, EventTriggerType.PointerClick, ConfirmClick); //确定
|
|
UIManager.AddEvent(backBtn, EventTriggerType.PointerClick, CancelClick); //取消
|
|
}
|
|
|
|
private void Refresh()
|
|
{
|
|
passwordInput.text = "";
|
|
}
|
|
|
|
private async void ConfirmClick(BaseEventData baseEventData)
|
|
{
|
|
if (string.IsNullOrEmpty(Password))
|
|
{
|
|
Utils.showToast(gameObject, App.GetLocalString("room password can not be empty"));
|
|
return;
|
|
}
|
|
var RoomId = manager.GetRoomId();
|
|
var result = await ConfigHelper.GameRoomApi.ConfirmRoomPwd(RoomId, Password);
|
|
if (!result.result)
|
|
{
|
|
Utils.showToast(gameObject, result.errMsg);
|
|
return;
|
|
}
|
|
Refresh();
|
|
gameObject.SetActive(false);
|
|
manager.ShowDownLoadConfirm();
|
|
}
|
|
private void CancelClick(BaseEventData baseEventData)
|
|
{
|
|
Refresh();
|
|
gameObject.SetActive(false);
|
|
}
|
|
}
|
|
|