Exemple #1
0
    private void Start()
    {
        socketIO = FindObjectOfType <SocketConnectionHandler>();

        // only show this menu when connected to the server
        gameObject.SetActive(false);
        socketIO.OnSocketEvent("connect", (_) =>
        {
            gameObject.SetActive(true);
        });

        socketIO.OnSocketEvent("disconnect", (_) =>
        {
            gameObject.SetActive(false);
        });
    }
    void Start()
    {
        socketIO = FindObjectOfType <SocketConnectionHandler>();

        // add messages to the text box
        socketIO.OnSocketEvent("game-message", eventData =>
        {
            TextElement.text = "> " + eventData.data + "\n" + TextElement.text;
        });
    }
Exemple #3
0
    void Start()
    {
        textElement = GetComponent <TMPro.TMP_Text>();
        Assert.IsNotNull(textElement);

        socketIO = FindObjectOfType <SocketConnectionHandler>();
        Assert.IsNotNull(socketIO);

        StartCoroutine(ConnectingAnimation());

        socketIO.OnSocketEvent("connect", (_) =>
        {
            StopAllCoroutines();
            StartCoroutine(ShowConnectionStatus(true));
        });

        socketIO.OnSocketEvent("disconnect", (_) =>
        {
            StopAllCoroutines();
            StartCoroutine(ShowConnectionStatus(false));
        });
    }