Unity MonoBehaviourPun and MonoBehaviourPunCallBacks not working

Options

On unity 2020.3.44f1 i did install photon pun 2 and when i went to code a script for it then when i finnished it i got this error.

Assets\Scripts\Lobby\LobbyManager.cs(6,36): error CS0234: The type or namespace name 'MonoBehaviourPun' does not exist in the namespace 'Photon' (are you missing an assembly reference?)

I have used the MonoBehaviourPun in the public class And i have re imported the entire project then the library folder then the ScriptAssemblies folder Now i lost the Assembly-C#.dll file from that. Nothing worked. I even re downloaded and imported the package from the package manager. When i import it it says all assets from this package are already in your project. Nothing to import. It only shows Pun 2 package in the my assets sction of the package manager. But not the in project. I have literly ran out of options on how to fix it. I cant find specific fix for it online. My assistant keeps telling me to download the unity package from the photon web site but it onlys redirects me to the unity asset store. Do you know how to fix it?

this is the code is it wrong?

using System.Collections.Generic;
using System.Collections;
using Photon.Realtime;
using UnityEngine.UI;
using UnityEngine;
using TMPro;


public class CreateRoom : MonoBehaviourPun
{
    [SerializeField]
    private TMPro.TextMeshProUGUI _roomName;


    
    public void OnClick_CreateRoom()
    {
        RoomOptions options = new RoomOptions();
        options.MaxPlayers = 4;
        PhotonNetwork.JoinOrCreateRoom(_roomName.text, options, TypedLobby.Default);

    }

    public override void OnCreatedRoom()
    {
        MasterManager.DebugConsole.AddText("Room Created successfully", this);
    }

    public override void OnCreateRoomFailed(short returnCode, string message)
    {
        MasterManager.DebugConsole.AddText("Room Faled to create; " + message, this);
    }
}


Comments

  • Tobias
    Tobias admin
    edited March 2023
    Options

    You need these using lines:

    using Photon.Pun;
    using Photon.Realtime;
    using UnityEngine;