54 lines
1.2 KiB
C#
54 lines
1.2 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using Photon.Pun;
|
|
using Photon.Realtime;
|
|
//The following script is made following this tutorial: https://www.youtube.com/watch?v=KHWuTBmT1oI
|
|
|
|
public class NetworkManager : MonoBehaviourPunCallbacks
|
|
{
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
ConnectToServer();
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
|
|
void ConnectToServer()
|
|
{
|
|
PhotonNetwork.ConnectUsingSettings();
|
|
Debug.Log("Connecting...");
|
|
}
|
|
|
|
public override void OnConnectedToMaster()
|
|
{
|
|
Debug.Log("Connected");
|
|
base.OnConnectedToMaster();
|
|
RoomOptions roomOptions = new RoomOptions();
|
|
roomOptions.MaxPlayers = 16;
|
|
roomOptions.IsVisible = true;
|
|
roomOptions.IsOpen = true;
|
|
|
|
PhotonNetwork.JoinOrCreateRoom("Room 1", roomOptions, TypedLobby.Default);
|
|
}
|
|
|
|
|
|
public override void OnJoinedRoom()
|
|
{
|
|
Debug.Log("Room joined");
|
|
base.OnJoinedRoom();
|
|
}
|
|
|
|
|
|
public override void OnPlayerEnteredRoom(Player newPlayer)
|
|
{
|
|
Debug.Log("Player joined");
|
|
base.OnPlayerEnteredRoom(newPlayer);
|
|
}
|
|
}
|