//void OnGUI () { void Update() { // When the server is started then issue a "LoadLevel" RPC call for the local GS client to load his own level // then also buffer the LoadLevel request so any new client that connects will also receive the "LoadLevel" if (Network.peerType != NetworkPeerType.Disconnected && mgs.gamemenustate == NetworkMasterServer.menustate.networklobby && Network.isServer) { // Make sure no old RPC calls are buffered and then send load level command Network.RemoveRPCsInGroup(0); Network.RemoveRPCsInGroup(1); // Load level with incremented level prefix (for view IDs) // NOTE: The RPCMode.AllBuffered sends the request to all clients, including the client sending the // request. Also, the Buffered command tells the game server to hold onto the RPC command and also // send it to any new clients that connect. This is important for level loading or player instantiation // so we make sure all objects are correctly created on all clients, but would not be used for example // to indicate a death as the new client would never have seen the player in the first place and // therefore doesn't need to see the death. /* This is the network call that every player who starts/joins a server. * Change "DefaultChatroom" to the name of the scene you want the player to load at first */ networkView.RPC("LoadLevel", RPCMode.AllBuffered, "DefaultChatroom", lastLevelPrefix + 1); } else if (Network.peerType != NetworkPeerType.Disconnected && !hasCreatedProxy) { proxy = VoiceChatUtils.CreateProxy(); hasCreatedProxy = true; } }
void OnConnectedToServer() { proxy = VoiceChatUtils.CreateProxy(); }