PUN2 - Can't add my class to CustomTypes.cs - "are you missing a using directive..."

Options
Hi there.
I've recently moved to PUN2 after successfully using PUN for another project for two past years. Now I'm seeing an issue with custom types that I have not experienced in PUN.

When I try to add any of my classes to CustomTypes.cs, they are not found. I am getting the "are you missing a using directive or an assembly reference?" error. My classes are public and are not part of any namespace.

The thing is, when I move the CustomTypes.cs class outside of the Assets/Photon/PhotonUnityNetworking/Code/ folder and place it in my Assets/Scripts/ folder, my classes can now be accessed in this file. However, then I am getting the same "missing a using directive" error from PhotonNetwork.cs about missing CustomTypes class.

Now, I know some Unity folder names can make some classes inaccessible from others because of the compilation order (https://docs.unity3d.com/Manual/ScriptCompileOrderFolders.html), but none of these folder names exist in this scenario.

Any help would be greatly appreciated!

Comments

  • Chisely
    Options
    After some more investigation I found out that the issue exists because the PhotonUnityNetworking folder now contains an Assembly Definition file to make Unity compile it into a single assembly without references to outside classes.

    I don't understand why the CustomTypes.cs script, where we're supposed to add our own classes is part of that assembly.

    How can I work around this issue?
  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @Chisely,

    There is no need or requirement to add your custom type methods and registration call to CustomTypes.cs.
    Add it to any other class or file where your other code can be referenced using assembly definitions.
  • Chisely
    Options
    Thank you JohnTube!

    So obvious now! I assumed that's the only place we can add Custom Types because PhotonNetwork calls it to register all the stuff inside.