Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- namespace PUNTutorial
- {
- public class GameManager : Photon.PunBehaviour {
- public static GameManager instance;
- public static GameObject localPlayer;
- void Awake()
- {
- if(instance != null)
- {
- DestroyImmediate(gameObject);
- return;
- }
- DontDestroyOnLoad(gameObject);
- instance = this;
- PhotonNetwork.automaticallySyncScene = true;
- }
- void Start()
- {
- PhotonNetwork.ConnectUsingSettings("PUNTutorial_Pt1");
- }
- public void JoinGame()
- {
- RoomOptions ro = new RoomOptions();
- ro.maxPlayers = 6;
- PhotonNetwork.JoinOrCreateRoom("Default Room", ro, null);
- }
- public override void OnJoinedRoom ()
- {
- Debug.Log("Joined Room");
- if(PhotonNetwork.isMasterClient)
- {
- PhotonNetwork.LoadLevel("Game Scene");
- }
- }
- void OnLevelWasLoaded(int levelNumber)
- {
- if (!PhotonNetwork.inRoom) return;
- localPlayer = PhotonNetwork.Instantiate(
- "Player",
- new Vector3(0,0.5f,0),
- Quaternion.identity, 0);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement