2023-09-04 12:48:24 +03:00
|
|
|
|
using BNG;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.Events;
|
|
|
|
|
using UnityEngine.XR;
|
|
|
|
|
|
|
|
|
|
public class DeviceDisconnectController : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
public UnityEvent OnTotalDisconnect;
|
|
|
|
|
|
|
|
|
|
private Coroutine coroutine;
|
|
|
|
|
private InputBridge inputBridge;
|
|
|
|
|
|
|
|
|
|
private void Awake()
|
|
|
|
|
{
|
|
|
|
|
inputBridge = GetComponent<InputBridge>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnEnable()
|
|
|
|
|
{
|
|
|
|
|
inputBridge.OnConnected.AddListener(OnDeviceConnected);
|
|
|
|
|
inputBridge.OnDisconnected.AddListener(OnDeviceDisconnected);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnDisable()
|
|
|
|
|
{
|
|
|
|
|
inputBridge.OnConnected.RemoveListener(OnDeviceConnected);
|
|
|
|
|
inputBridge.OnDisconnected.RemoveListener(OnDeviceDisconnected);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnDeviceConnected()
|
|
|
|
|
{
|
|
|
|
|
if (coroutine != null)
|
|
|
|
|
{
|
|
|
|
|
StopCoroutine(coroutine);
|
|
|
|
|
coroutine = null;
|
2023-09-05 17:38:11 +03:00
|
|
|
|
UIInfoDisplay.Instance.HideInfo(DisplayMessageType.DeviceLost);
|
2023-09-04 12:48:24 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnDeviceDisconnected()
|
|
|
|
|
{
|
|
|
|
|
if (coroutine != null)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
coroutine = StartCoroutine(DisconnectTime());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private IEnumerator DisconnectTime()
|
|
|
|
|
{
|
2023-09-05 17:38:11 +03:00
|
|
|
|
UIInfoDisplay.Instance.ShowInfo(DisplayMessageType.DeviceLost);
|
|
|
|
|
Debug.Log("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>");
|
2023-09-04 12:48:24 +03:00
|
|
|
|
yield return new WaitForSeconds(15);
|
2023-09-18 20:09:22 +03:00
|
|
|
|
SceneLoader.Instance.LoadScene("StartScene");
|
2023-09-04 12:48:24 +03:00
|
|
|
|
OnTotalDisconnect?.Invoke();
|
|
|
|
|
}
|
|
|
|
|
}
|