Last active
February 28, 2016 11:18
-
-
Save eelstork/9eba6991cfdf813639e0 to your computer and use it in GitHub Desktop.
A component that connects to Photon Unity Network and joins or creates a room.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
public class PUNNetworkController : MonoBehaviour { | |
void Start(){ PhotonNetwork.ConnectUsingSettings("v4.2"); } | |
void OnJoinLobby(){ StartGame (); } | |
void OnConnectedToMaster(){ StartGame (); } | |
void StartGame(){ PhotonNetwork.JoinRandomRoom(); } | |
void OnPhotonRandomJoinFailed(){ PhotonNetwork.CreateRoom("MyMatch"); } | |
void OnPhotonCreateGameFailed(){ Debug.LogError ("Create game failed"); } | |
void OnJoinedRoom(){ Debug.Log ("Room joined; ready to start the game"); } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment