コード例 #1
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);
        }
コード例 #2
0
ファイル: Player.cs プロジェクト: zabszk/Mirror
        /// <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);
        }
コード例 #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()
        {
            // 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();
            }
        }
コード例 #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()
        {
            // 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);
        }
コード例 #5
0
 // This is called by the hook of playerColor SyncVar above
 void PlayerColorChanged(Color32 _, Color32 newPlayerColor)
 {
     OnPlayerColorChanged?.Invoke(newPlayerColor);
 }
コード例 #6
0
ファイル: Level.cs プロジェクト: Falcotte/Color-Bump-3D-Clone
 public void PlayerColorChanged()
 {
     OnPlayerColorChanged?.Invoke();
 }