Skip to content

Instantly share code, notes, and snippets.

@sim2kid
Created July 25, 2024 21:10
Show Gist options
  • Save sim2kid/8cba3f5e7db9aa0d3772c9c8f992cc9c to your computer and use it in GitHub Desktop.
Save sim2kid/8cba3f5e7db9aa0d3772c9c8f992cc9c to your computer and use it in GitHub Desktop.
FieldAccessException in Photon Fusion 2

Issue

When running in Photon Fusion 2, you may run into an error similar to below:

FieldAccessException: Field `Fusion.NetworkBehaviour:Ptr` is inaccessible from method `METHOD_NAME`

This seemingly seems to be that Fusion is not allowing Networked Objects from accessing their own networked properties.

Solution

This error occurs if the "Allow 'unsafe' Code" option is unchecked in PlayerSettings. When enabled, the error will stop occuring.

About Assemblies

If you have networked objects in any assemblies, you'll also need to set "Allow 'unsafe' Code" on the Asmdef file too. Tip: Don't forget to include this new assembly when weaving networked objects.

Credit

Thank you to @kazuki_kuriyama from Qiita for posting about this previously.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment