- Home /
The type or namespace name 'Pun' does not exist in the namespace 'Photon'
Getting this error when trying to use Photon PUN 2 - Free
The type or namespace name 'Pun' does not exist in the namespace 'Photon'
Here's the code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
public class NetworkController : MonoBehaviourPunCallbacks
{
// Start is called before the first frame update
void Start()
{
PhotonNetwork.ConnectUsingSettings();
}
public override void OnConnectedToMaster()
{
Debug.Log("connected to " + PhotonNetwork.CloudRegion + " server");
}
// Update is called once per frame
void Update()
{
}
}
Answer by KillitsGaming · Jul 06, 2021 at 05:31 AM
Hi, I don't know if you still need it but for me to get to work. I had to Regenerate the project Files in external tools.
Damn, thanks man!! This solution fixed the problem instantly. In Unity Editor on the top left go Edit > Preferences > External Tools > Regenerate project Files
Answer by HernandoNJ · May 06, 2020 at 04:08 AM
I had the same issue in 2019.3.12 version after installing PUN2 pack. When I created a new script, the Photon
options Chat
and Realtime
were enabled, but not the option
using Photon.Pun;
I tried to use 2019.3.5 and the issue didn't appear. I suggest you to use a different version and import your assets. At least the issue should not appear so, your scripts should work fine.
Answer by squarelover · Dec 01, 2020 at 03:59 PM
have to add references manually to assmebly definition files in inspector for each project that used it
Answer by MrGreenish · Sep 15, 2021 at 03:14 AM
If nothing else works try these one at the time and then try to see if it's working, this worked for me. 1. Re-import PUN from the package manager in Unity. 2. Update Visual studio and restart the computer. 3. Go to Edit->Preferences->External Script Editor and then browse to the location of Visual Studio .exe file.
Answer by CrimSilk · Jun 14, 2020 at 11:52 AM
For me it was an issue with my assemblies. I had an assembly file in the root of my Assets folder.
I moved it to my Scripts folder so is wasn't blocking any of the Photon assemblies.
So make sure to check your assembly references.
I tried this, It kinda worked and Photon can be detected on VS but it affects the intellisense. Best option is the top voted one
Your answer
![](https://koobas.hobune.stream/wayback/20220612230747im_/https://answers.unity.com/themes/thub/images/avi.jpg)