The type or namespace name 'Pun' does not exist in the namespace 'Photon'
Asked Answered
J

9

0

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");
    }
}
Justify answered 7/2, 2024 at 16:31 Comment(0)
N
0

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.

Nimiety answered 6/6, 2023 at 2:30 Comment(0)
S
0

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.

Sufflate answered 14/6, 2020 at 11:52 Comment(1)

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

Mccorkle
D
0

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.

Delegate answered 2/8, 2020 at 14:45 Comment(1)

@Delegate I dont really understand that can u make a video on how to do that

Socinian
C
0

have to add references manually to assmebly definition files in inspector for each project that used it

Colpotomy answered 7/8, 2023 at 13:39 Comment(0)
C
0

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.

Callous answered 25/5, 2021 at 15:30 Comment(0)
L
0

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.

Landside answered 6/9, 2023 at 11:32 Comment(2)

Damn, thanks man!! This solution fixed the problem instantly. In Unity Editor on the top left go Edit > Preferences > External Tools > Regenerate project Files

Dactylography

This also worked for me.

Mccorkle
C
0

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.
Chanticleer answered 15/9, 2021 at 3:14 Comment(0)
T
0

I had imported Photon then got this error. Then i noticed i had to import Photon 2. After that my errors where gone.

Trigg answered 17/7, 2023 at 13:16 Comment(0)
R
0

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!

Readiness answered 7/2, 2024 at 15:44 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.