Photon Unity Networking
Photon Unity Networking (PUN) is being put into Long Term Support mode as of July 2021. We are finishing Fusion, our state of the art, MonoBehaviour-based networking solution. Fusion is recommended for all recent and new projects!
PUN support will continue but there are no major changes planned. The Photon Cloud will also continue to support existing games indefinitely.
Download: PUN 2 Free from the Asset Store.
Overview
This package implements a comfortable Unity-specific networking API on top of Photon.
Keeping the API simple, this gives you dedicated servers, matchmaking, in-game communication, fixes, tweaks and ongoing support.
This package contains a setup wizard, the fully integrated API, Editor extensions and the client library. It’s compatible with the Photon Cloud Service, so you don’t even have to setup a server!
Requirements
Unity 2018.4 or up.
Server Options
- Photon Cloud Service: www.photonengine.com/en/Realtime
Free for 20 concurrent users. - Photon Standalone server: www.photonengine.com/en-US/OnPremise/Download
Free 100 concurrent users (CCU) license. Registration required.
PUN 2
There are two “PUN 2” packages in the Asset Store: Both contain the same content, so everyone can just get and use the Free package. The Plus package includes a 100 CCU subscription, which is good for a bigger test group or an early soft launch (100 CCU cover approximately 40k monthly active users).
What’s new?! PUN 2 has a new structure and comes in just one “root” folder. We cleaned up the naming of many classes, fields and interfaces and there is a new callback system. We created new demos and are in the process of re-writing the documentation (note the v2 in the link). Currently the API reference is only in the package (see the PDF or CHM files). Updating existing projects will be quite some work. Here are the migration notes we took.
Should I update from PUN Classic? Definitely! PUN Classic is outdated.
Existing subscriptions (e.g. of a previously purchased PUN Classic Plus) can be used with PUN 2. There is no upgrade fee whatsoever.
Reply here or mail to: developer@photonengine.com.
Release History
(recent releases)
v2.47 (02. September 2024)
Fixed: PhotonNetwork.PunVersion to “2.47”. Accidentally v2.46 used “2.45” as well.
Updated: Library, Realtime and Chat API to 4.1.8.9. More details in the change logs.
v2.46 (26. April 2024)
Changed: PhotonStream serialization: Char values are cast to short before being sent (receivers will simply get a short but can cast accordingly).
Added: PhotonStream.Serialize(ref byte value).
Checked: Compatibility with Unity 2022.2.20 (soon to be Unity 6). All good.
Updated: Library, Realtime and Chat API to 4.1.8.4. More details in the change logs.
v2.45 (05. February 2024)
Fixed: OpJoinRandomOrCreateRoom and OpJoinRandomRoom. The last version introduced an issue with random matchmaking, when using MaxPlayers as filter to find rooms. It caused clients never to find fitting rooms in those conditions.
Updated: Library, Realtime and Chat API to 4.1.8.0.
v2.44 (14. December 2023)
Updated: Library, Realtime and Chat API to 4.1.7.4. Fixes and changes for Best Region Selection and reporting client timeouts to server. More in the related change logs.
Updated: PUN Wizard panel. Replaced forum link with pointer to join our Discord.
v2.43 (21. August 2023)
Updated: Library, Realtime and Chat API to 4.1.7.0. This includes many improvements for WebSockets and connection-loss debugging (specifically for UDP, SocketUdp class). More in the related change logs.
Updated: To Unity 2019.4.
Fixed: PUN Basics GameManager to not accidentally send the network Instantiate request before joining the room (which could happen if the scene was loading too fast). See comments in OnJoinedRoom().
Fixed: PUN Basics GUI Button call of LeaveRoom by removing the return value from the called method. It failed with the error “Method arguments are incompatible”. Adjusted related code (minimally).
Changed: Procedural Demo now randomizes the initial “seed” value. “Nice to have” addition.
Changed: Demo Hub to include Procedural Demo.
v2.42 (15. May 2023)
Updated: Library, Realtime and Chat API to 4.1.6.24. More details in the change logs.
v2.41 (02. August 2022)
Changed: PhotonHandler.MaxDatagrams to 10. The previous value was unnecessary low.
Changed: PhotonHandler sending to send more datagrams in the next frame, if it has more than MaxDatagrams queued in any frame.
Updated: Library, Realtime and Chat API to 4.1.6.17. More details in the change logs.
v2.40 (22. November 2021)
Fixed: Unity 2021.2 support. PhotonEditorUtils.IsPrefab now uses the correct prefab stage utility for Unity 2021.2 and up.
Changed: PhotonHandler.Dispatch is now catching exceptions. It will count them but only provide the first one’s callstack (to avoid log spamming).
Note: While the Photon lib caught exceptions in v4.1.6.10, that has not been a good solution. This new approach can be changed in source and is more flexible overall.
Changed: On Xbox, the peer classes no longer assume a native socket plugin exists. This was setting the UDP implementation to null in some cases, which failed to connect.
Updated: Library and Realtime to 4.1.6.11. More details in the change logs.
Release History
All updates are detailed in the changelog.txt in the package.
Download
PUN 2 in the Asset Store
Special thanks go to Jean, Vadim, Davin, Leepo, Hamza and Olli for their great work, feedback and support.
Upcoming
PUN is in Long Term Support (LTS) mode, which means we will support it for existing projects and keep it compatible with existing platforms. Of course, we keep the Photon Cloud compatible, too. However, bigger changes are no longer planned for PUN 2 anymore.
Photon Fusion is our state of the art, MonoBehaviour-based networking solution. Fusion is recommended for all recent and new projects.
Feedback is welcome! Just reply here. Mail us for complicated topics and console support.
This post will be edited over time with more info, updates, etc.