The type or namespace name 'Pun' does not exist in the namespace 'Photon'.

The whole answer can be found below.

Please note: The Photon forum is closed permanently. After many dedicated years of service we have made the decision to retire our forum and switch to read-only: we've saved the best to last! And we offer you support through these channels:

Try Our
Documentation

Please check if you can find an answer in our extensive documentation on PUN.

Join Us
on Discord

Meet and talk to our staff and the entire Photon-Community via Discord.

Read More on
Stack Overflow

Find more information on Stack Overflow (for Circle members only).

Write Us
an E-Mail

Feel free to send your question directly to our developers.

The type or namespace name 'Pun' does not exist in the namespace 'Photon'.

relevantname
2019-08-25 18:02:51

Hi,

I imported PUN to my Unity project. But when I wanted to use PhotonNetowork class, Unity gets error;
'The type or namespace name 'Pun' does not exist in the namespace 'Photon''. (I add the namespace like 'using Photon.Pun'.

I get this error even I created a clean project.

How can I solve this?

Thanks in advance.

Comments

relevantname
2019-08-25 19:12:03

Solution:
I created an assembly definition to my Scripts folder, and add all Photon dll's to this assembly definition's Assembly Definition References list. This solve the problem. But I have no idea why? Is it Unity related problem?

Cutterz68
2020-05-04 04:01:00

I've just started the first PUN 2 tutorial and the first line of code I typed caused the issue you described:

using Photon.Pun;

Trouble is, I don't know how to 'create an assembly definition to my Scripts folder, and add all Photon DLLs to this assembly definition's Assembly Definition References list'.

Could you possibly point me in the right direction?

I'd be ever so grateful if you could. 😊

Cutterz68
2020-05-08 19:34:31

@Cutterz68 wrote: »

I've just started the first PUN 2 tutorial and the first line of code I typed caused the issue you described:

using Photon.Pun;

Trouble is, I don't know how to 'create an assembly definition to my Scripts folder, and add all Photon DLLs to this assembly definition's Assembly Definition References list'.

Could you possibly point me in the right direction?

I'd be ever so grateful if you could. 😊

I've just updated my Unity Editor and opened the project, and now it seems fine. Not sure why, but at least now it works.

chielos
2020-07-28 17:59:38

This is what fixed it:

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.

Tobias
2020-07-30 10:07:14

@chielos, thanks for the head up.
Overall, I have to say, UnityScript is not really a supported language anymore. The JavaScript compiler is being removed from newer Unity versions, so it may be time to move over to cs.

DRRosen3
2021-02-01 20:57:31

This isn't a UnityScript/JavaScript issue. It exists in 2020.2 version of Unity while using C# and Visual Studio 2017 (Community) or Visual Studio 2015.

kb_gemu
2022-04-16 13:53:25

using Photon.Pun not working in any unity version . Pls help me out!!!!!!!

devonlively
2022-04-16 18:23:01

did you follow the steps mentioned above?

Kerem
2022-06-29 15:27:14

Pun2 delete and redowland that working

Back to top