I am following a tutorial on how to create a multiplayer game and I am having several errors and including this one:
Assets\Scripts\MainMenu.cs(9,29):
error CS0246: The type or namespace
name ‘MonoBehaviourPunCallBacks’ could
not be found (are you missing a using
directive or an assembly reference?)
Anyone know what is what is happening
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
namespace PhotonTutorials.Menus
{
public class MainMenu : MonoBehaviourPunCallBacks
{
[SerializeField] private GameObject findOpponentPanel = null;
[SerializeField] private GameObject waitingStatusPanel = null;
[SerializeField] private TextMeshProUGUI waitingStatusText = null;
private bool isConnecting = false;
private const string GameVersion = "0.1";
private const int MaxPlayersPerRoom = 2;
private void Awake() => PhotonNetwork.AutomaticallySyncScene = true;
public void FindOpponent()
{
isConnecting = true;
findOpponentPanel.SetActive(false);
waitingStatusPanel.SetActive(true);
waitingStatusText.text = "Searching..";
if (PhotonNetwork.IsConnected)
{
PhotonNetwork.JoinRandomRoom();
}
else
{
PhotonNetwork.GameVersion = GameVersion;
PhotonNetwork.ConnectUsingSettings();
}
}
public override void OnConnectedToMaster()
{
Debug.Log("Connected To Master");
if (isConnecting)
{
PhotonNetwork.JoinRandomRoom();
}
}
public override void OnDisconnected(DisconnectCause cause)
{
waitingStatusPanel.SetActive(false);
findOpponentPanel.SetActive(true);
Debug.Log($"Disconnected due to: {cause}");
}
public override void OnJoinRandomFailed(short returnCode, string message)
{
Debug.Log("No clients are waiting for an opponent, creating a new room");
PhotonNetwork.CreateRoom(null, new RoomOptions { MaxPlayers = MaxPlayersPerRoom });
}
public override void OnJoinedRoom()
{
Debug.Log("Client successfully joined a room");
int playerCount = PhotonNetwork.CurrentRoom.PlayerCount;
if (playerCount != MaxPlayersPerRoom)
{
waitingStatusText.text = "Waiting For Opponent";
Debug.Log("Client is waiting for a opponent");
}
else
{
waitingStatusText.text = "Opponent Found";
Debug.Log("Mactcing is ready to begin");
}
}
public override void OnPlayerEnteredRoom(Player newPlayer)
{
if (PhotonNetwork.CurrentRoom.PlayerCount == MaxPlayersPerRoom)
{
PhotonNetwork.CurrentRoom.IsOpen = false;
waitingStatusText.text = "Opponent Found";
Debug.Log("Match is ready to begin");
PhotonNetwork.LoadLevel("Scene_Main");
}
}
}
}