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
{
void Start ()
{
PhotonNetwork.ConnectUsingSettings();
}
public override void OnConnectedToMaster ()
{
Debug.Log("connected to "+PhotonNetwork.CloudRegion+" server");
}
}
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.
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.
I had imported Photon then got this error. Then i noticed i had to import Photon 2. After that my errors where gone.
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.
UnityScript / JavaScript
PUN is written with C# in mind primarily.
To use PUN from UnityScript, you need to move some folders in your project.
Move both folders “PhotonNetwork” and “UtilityScripts” to the Assets\Plugins\ folder.
from: \Photon Unity Networking\Plugins
and: \Photon Unity Networking
to: \Plugins
Now PUN compiles before UnityScript and that makes it available from regular UnityScript code.
have to add references manually to assmebly definition files in inspector for each project that used it
All you have to do to fix this problem is go to Package manager and install “visual studio editor package”
windows>Package Manager> All Packages /or Unity Registry (depeding on your unity version)
search of visual studio editor
edit : if it’s already installed delete it and reinstall.
If nothing else works try these one at the time and then try to see if it’s working, this worked for me.
- Re-import PUN from the package manager in Unity.
- Update Visual studio and restart the computer.
- Go to Edit->Preferences->External Script Editor and then browse to the location of Visual Studio .exe file.
what was the context of this error, because I have had issues building the apk, when I build it its fine, but then I add photon and it doesnt work, is this why? I cant check the error right now because I am at school, but if anyone knows how to fix the apk building, please let me know, or if this is how you fix it, thats great!