Example #1
0
    void OnGUI()
    {
        if (manager == null)
        {
            manager = GetComponent <NetworkManager>();
        }
        if (tta == null)
        {
            tta = GetComponent <TimedTicketAuthenticator>();
        }

        GUIStyle button = new GUIStyle(GUI.skin.GetStyle("button"));
        //button.fontSize = 32;
        GUIStyle label = new GUIStyle(GUI.skin.GetStyle("label"));

        //label.fontSize = 32;
        GUILayout.BeginArea(new Rect(10 + offsetX, 40 + offsetY, 600, 9999));
        if (!NetworkClient.isConnected)
        {
            if (!NetworkClient.active)
            {
                GUILayout.Label("Ticket:", label);
                ticket = GUILayout.TextField(ticket /*, label*/);
                //Debug.Log(String.Format("Ticket: {0}", ticket));
                if (tta != null && !String.IsNullOrEmpty(ticket))
                {
                    tta.ticketString = ticket;
                }
                string precheckStatus;
                if (tta.PrecheckTicket(out precheckStatus) && GUILayout.Button("Join with ticket", button))
                {
                    Debug.Log("Start client with ticket " + ticket);
                    manager.StartClient(new Uri(serverUri));
                }
            }
            else
            {
                // Connecting
                GUILayout.Label("Joining...", label);
                if (GUILayout.Button("Cancel join Attempt", button))
                {
                    manager.StopClient();
                }
            }
        }
        else
        {
            if (GUILayout.Button("Leave", button))
            {
                manager.StopClient();
            }
        }
        GUILayout.Label("Status: " + tta.clientStatus, label);
        GUILayout.EndArea();
    }