public override void OnStartClient()
    {
        // Instantiate the player UI as child of the Players Panel
        playerUI = Instantiate(playerUIPrefab, ((MainNetworkManager)NetworkManager.singleton).playersPanel);

        // Set this player object in PlayerUI to wire up event handlers
        playerUI.GetComponent <PlayerUI>().SetPlayer(this, isLocalPlayer);

        // Invoke all event handlers with the current data

        OnPlayerNumberChanged.Invoke(playerNumber);
        OnPlayerScoreChanged.Invoke(playerScore);
    }
Exemplo n.º 2
0
        /// <summary>
        /// Called on every NetworkBehaviour when it is activated on a client.
        /// <para>Objects on the host have this function called, as there is a local client on the host. The values of SyncVars on object are guaranteed to be initialized correctly with the latest state from the server when this function is called on the client.</para>
        /// </summary>
        public override void OnStartClient()
        {
            // Activate the main panel
            ((BasicNetManager)NetworkManager.singleton).mainPanel.gameObject.SetActive(true);

            // Instantiate the player UI as child of the Players Panel
            playerUI = Instantiate(playerUIPrefab, ((BasicNetManager)NetworkManager.singleton).playersPanel);

            // Set this player object in PlayerUI to wire up event handlers
            playerUI.GetComponent <PlayerUI>().SetPlayer(this, isLocalPlayer);

            // Invoke all event handlers with the current data
            OnPlayerNumberChanged.Invoke(playerNumber);
            OnPlayerColorChanged.Invoke(playerColor);
            OnPlayerDataChanged.Invoke(playerData);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Called on every NetworkBehaviour when it is activated on a client.
        /// <para>Objects on the host have this function called, as there is a local client on the host. The values of SyncVars on object are guaranteed to be initialized correctly with the latest state from the server when this function is called on the client.</para>
        /// </summary>
        public override void OnStartClient()
        {
            Debug.Log("OnStartClient");

            // Instantiate the player UI as child of the Players Panel
            playerUIObject = Instantiate(playerUIPrefab, CanvasUI.instance.playersPanel);
            playerUI       = playerUIObject.GetComponent <PlayerUI>();

            // wire up all events to handlers in PlayerUI
            OnPlayerNumberChanged = playerUI.OnPlayerNumberChanged;
            OnPlayerColorChanged  = playerUI.OnPlayerColorChanged;
            OnPlayerDataChanged   = playerUI.OnPlayerDataChanged;

            // Invoke all event handlers with the initial data from spawn payload
            OnPlayerNumberChanged.Invoke(playerNumber);
            OnPlayerColorChanged.Invoke(playerColor);
            OnPlayerDataChanged.Invoke(playerData);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Called on every NetworkBehaviour when it is activated on a client.
        /// <para>Objects on the host have this function called, as there is a local client on the host. The values of SyncVars on object are guaranteed to be initialized correctly with the latest state from the server when this function is called on the client.</para>
        /// </summary>
        public override void OnStartClient()
        {
            // Instantiate the player UI as child of the Players Panel
            playerUIObject = Instantiate(playerUIPrefab, CanvasUI.instance.playersPanel);
            PlayerUI playerUI = playerUIObject.GetComponent <PlayerUI>();

            // wire up all events to handlers in PlayerUI
            OnPlayerNumberChanged = playerUI.OnPlayerNumberChanged;
            OnPlayerColorChanged  = playerUI.OnPlayerColorChanged;
            OnPlayerDataChanged   = playerUI.OnPlayerDataChanged;

            // Invoke all event handlers with the initial data from spawn payload
            OnPlayerNumberChanged.Invoke(playerNumber);
            OnPlayerColorChanged.Invoke(playerColor);
            OnPlayerDataChanged.Invoke(playerData);

            // Set isLocalPlayer for this Player in UI for background shading
            if (isLocalPlayer)
            {
                playerUI.SetLocalPlayer();
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Called on every NetworkBehaviour when it is activated on a client.
        /// <para>Objects on the host have this function called, as there is a local client on the host. The values of SyncVars on object are guaranteed to be initialized correctly with the latest state from the server when this function is called on the client.</para>
        /// </summary>
        public override void OnStartClient()
        {
            // Activate the main panel
            ((BasicNetManager)NetworkManager.singleton).mainPanel.gameObject.SetActive(true);

            // Instantiate the player UI as child of the Players Panel
            playerUI = Instantiate(playerUIPrefab, ((BasicNetManager)NetworkManager.singleton).playersPanel);

            // this fixes the ar camera issue for multiple cameras
            if (GameObject.Find("ARCamera(Clone)") == null)
            {
                GameObject arcam = Instantiate(arCameraPrefab);
            }

            // Set this player object in PlayerUI to wire up event handlers
            playerUI.GetComponent <PlayerUI>().SetPlayer(this, isLocalPlayer);

            // Invoke all event handlers with the current data
            OnPlayerNumberChanged.Invoke(playerNumber);
            OnPlayerColorChanged.Invoke(playerColor);
            OnPlayerDataChanged.Invoke(playerData);
        }
 // This is called by the hook of playerNumber SyncVar above
 void PlayerNumberChanged(int _, int newPlayerNumber)
 {
     OnPlayerNumberChanged?.Invoke(newPlayerNumber);
 }
Exemplo n.º 7
0
 // This is called by the hook of playerNumber SyncVar above
 void PlayerNumberChanged(byte _, byte newPlayerNumber)
 {
     OnPlayerNumberChanged?.Invoke(newPlayerNumber);
 }