Skip to content
Snippets Groups Projects
WaitingForLocalMMT.cs 1.65 KiB
Newer Older
  • Learn to ignore specific revisions
  • using UnityEngine;
    using UnityEngine.SceneManagement;
    
    using static UIconfig;
    
    public class WaitingForLocalMMT : MonoBehaviour
    {
    
    
        private void Start()
        {
    
        }
    
        private void Update()
        {
    
    
        }
        private void OnEnable()
        {
            StartCoroutine(ServerRoutine());
        }
    
        private void OnDisable()
        {
            StopCoroutine(ServerRoutine());
        }
    
        void PrepareGame()
        {
            if (true)
            {
    
                CommunicationEvents.ServerRunning = true;
    
            if (CommunicationEvents.ServerRunning == true)
            {
                CommunicationEvents.ServerAdress = CommunicationEvents.ServerAddressLocal;
    
                SceneManager.LoadScene("MainMenue");
            }
    
    
    
                using UnityWebRequest request = UnityWebRequest.Get(CommunicationEvents.ServerAddressLocal + "/scroll/list");
                yield return request.SendWebRequest();
                if (request.result == UnityWebRequest.Result.ConnectionError
                 || request.result == UnityWebRequest.Result.ProtocolError)
                {
                    // UnityEngine.Debug.Log("no running server");
                }
                else
                {
                    //break;
                    PrepareGame();
                }
    
    
                //Wait for 2 seconds
                yield return new WaitForSecondsRealtime(2f);