您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
59 行
1.6 KiB
59 行
1.6 KiB
using System;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using VContainer;
|
|
|
|
namespace Unity.Multiplayer.Samples.BossRoom.Visual
|
|
{
|
|
public class IPJoiningUI : MonoBehaviour
|
|
{
|
|
[SerializeField]
|
|
CanvasGroup m_CanvasGroup;
|
|
|
|
[SerializeField] InputField m_IPInputField;
|
|
|
|
[SerializeField] InputField m_PortInputField;
|
|
|
|
[Inject] IPUIMediator m_IPUIMediator;
|
|
|
|
void Awake()
|
|
{
|
|
m_IPInputField.text = IPUIMediator.k_DefaultIP;
|
|
m_PortInputField.text = IPUIMediator.k_DefaultPort.ToString();
|
|
}
|
|
|
|
public void Show()
|
|
{
|
|
m_CanvasGroup.alpha = 1f;
|
|
m_CanvasGroup.blocksRaycasts = true;
|
|
}
|
|
|
|
public void Hide()
|
|
{
|
|
m_CanvasGroup.alpha = 0f;
|
|
m_CanvasGroup.blocksRaycasts = false;
|
|
}
|
|
|
|
public void OnJoinButtonPressed()
|
|
{
|
|
m_IPUIMediator.JoinWithIP(m_IPInputField.text, m_PortInputField.text);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Added to the InputField component's OnValueChanged callback for the Room/IP UI text.
|
|
/// </summary>
|
|
public void SanitizeIPInputText()
|
|
{
|
|
m_IPInputField.text = IPUIMediator.Sanitize(m_IPInputField.text);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Added to the InputField component's OnValueChanged callback for the Port UI text.
|
|
/// </summary>
|
|
public void SanitizePortText()
|
|
{
|
|
var inputFieldText = IPUIMediator.Sanitize(m_PortInputField.text);
|
|
m_PortInputField.text = inputFieldText;
|
|
}
|
|
}
|
|
}
|