///NetworkManager.cs using System.Collections; using System.Collections.Generic; using UnityEngine; using Photon.Pun; using Photon.Realtime; public class NetworkManager : MonoBehaviourPunCallbacks { void Start() { Connect(); } public void Connect() { PhotonNetwork.ConnectUsingSettings(); } public void Play() { PhotonNetwork.JoinRandomRoom(); } public override void OnJoinRandomFailed(short returnCode, string message) { Debug.Log("Tried to join a room and failed"); PhotonNetwork.CreateRoom(null, new RoomOptions { MaxPlayers = 4 }); } public override void OnJoinedRoom() { Debug.Log("Joined a Room ---yay"); } void Update() { // Add any additional update logic if needed } }
///NetworkManager.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
using Photon.Realtime;
public class NetworkManager : MonoBehaviourPunCallbacks
{
void Start()
{
Connect();
}
public void Connect()
{
PhotonNetwork.ConnectUsingSettings();
}
public void Play()
{
PhotonNetwork.JoinRandomRoom();
}
public override void OnJoinRandomFailed(short returnCode, string message)
{
Debug.Log("Tried to join a room and failed");
PhotonNetwork.CreateRoom(null, new RoomOptions { MaxPlayers = 4 });
}
public override void OnJoinedRoom()
{
Debug.Log("Joined a Room ---yay");
}
void Update()
{
// Add any additional update logic if needed
}
}