Net_Ease_Dome/Assets/Scripts/Tips.cs

83 lines
1.5 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System;
using UnityWebSocket;
public class Tips : MonoBehaviour {
#region Judge
[SerializeField]
private Text Title;
[SerializeField]
private Text Information;
[SerializeField]
private Button Yes;
[SerializeField]
private Button No;
private Action<bool> OnChoose;
#endregion
#region Confrom
[SerializeField]
private Button Confrom;
private Action OnConform;
#endregion
// Use this for initialization
void Start () {
Confrom.onClick.AddListener(() =>
{
Confrom.interactable = false;
Invoke("ShowDelay",3);
if (WebSocketDemo.socket_main != null && WebSocketDemo.socket_main.ReadyState == WebSocketState.Closed)
{
WebSocketDemo.socket_main.ConnectAsync();
}
if(WebSocketDemo.socket_trans != null && WebSocketDemo.socket_trans.ReadyState == WebSocketState.Closed)
{
WebSocketDemo.socket_trans.ConnectAsync();
}
});
}
public void TipJudge(string title,string info,Action<bool> callback)
{
Title.text = title;
Information.text = info;
OnChoose = callback;
}
public void TipConform()
{
gameObject.SetActive(true);
}
/// <summary>
/// 重连成功
/// </summary>
public void TipHide()
{
Confrom.interactable = true;
gameObject.SetActive(false);
}
/// <summary>
/// 尝试重连后禁止操作
/// </summary>
private void ShowDelay()
{
Confrom.interactable = true;
}
}