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

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

  • 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?
  • 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 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.
  • 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.
  • @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.
  • 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.
  • using Photon.Pun not working in any unity version . Pls help me out!!!!!!!

  • did you follow the steps mentioned above?

  • Pun2 delete and redowland that working