Munchy2007

PunTutPart3_2

Aug 18th, 2016
11,880
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.80 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. namespace PUNTutorial
  5. {
  6.     public class GameManager : Photon.PunBehaviour {
  7.         public static GameManager instance;
  8.  
  9.         void Awake()
  10.         {
  11.             if(instance != null)
  12.             {
  13.                 DestroyImmediate(gameObject);
  14.                 return;
  15.             }
  16.             DontDestroyOnLoad(gameObject);
  17.             instance = this;
  18.  
  19.             PhotonNetwork.automaticallySyncScene = true;
  20.         }
  21.  
  22.         void Start()
  23.         {
  24.             PhotonNetwork.ConnectUsingSettings("PUNTutorial_Pt1");
  25.         }
  26.  
  27.         public void JoinGame()
  28.         {
  29.             RoomOptions ro = new RoomOptions();
  30.             ro.maxPlayers = 6;
  31.             PhotonNetwork.JoinOrCreateRoom("Default Room",  ro, null);
  32.         }
  33.  
  34.         public override void OnJoinedRoom ()
  35.         {
  36.             Debug.Log("Joined Room");
  37.  
  38.             if(PhotonNetwork.isMasterClient)
  39.             {
  40.                 PhotonNetwork.LoadLevel("Game Scene");
  41.             }
  42.         }
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment