Exemple #1
0
    // Client callbacks
    public override void OnClientConnect(NetworkConnection conn)
    {
        PlayerTypeMessage playerTypeMessage = new PlayerTypeMessage();

        if (XRDevice.isPresent)
        {
            playerTypeMessage.playerType = PlayerType.VrPlayerType;
        }
        else
        {
            playerTypeMessage.playerType = PlayerType.MobilePlayerType;
        }
        ClientScene.AddPlayer(conn, 0, playerTypeMessage);
        mobileNetworkUi.SetActive(false);
    }
Exemple #2
0
    public override void OnServerAddPlayer(NetworkConnection conn, short playerControllerId, NetworkReader extraMessageReader)
    {
        PlayerTypeMessage playerTypeMessage = extraMessageReader.ReadMessage <PlayerTypeMessage>();
        PlayerType        playerType        = playerTypeMessage.playerType;

        if (playerType == PlayerType.VrPlayerType)
        {
            var player = (GameObject)GameObject.Instantiate(vrPlayer, Vector3.zero, Quaternion.identity);
                NetworkServer.AddPlayerForConnection(conn, player, playerControllerId);
        }
        else if (playerType == PlayerType.MobilePlayerType)
        {
            var player = (GameObject)GameObject.Instantiate(mobilePlayer, blueSpawnPoint.transform.position, Quaternion.identity);
                NetworkServer.AddPlayerForConnection(conn, player, playerControllerId);
        }
    }