Photon Unity Networking Get it. No server setup needed - runs in the Photon Cloud. Includes a free plan - no obligations. Exports to all major platforms. 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, authentication integration, matchmaking, first-class 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 v5.3 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. Existing subscriptions (e.g. of a previously purchased PUN Plus) can be used with PUN 2. There is no upgrade fee or such! If you got an existing 100 CCU subscription, you can use that. Existing AppIDs can be used in PUN 2 (and vice versa). Why a second package then?! PUN 2 wraps up a lot of internal refactoring and includes multiple breaking changes for existing PUN projects. As we don't want to break existing projects, PUN 2 got separate packages. Should I update? Bigger or almost complete projects should probably stick with PUN "Classic". We will keep that package around and update it but we probably won't add more features. Projects starting recently or soon, should use PUN 2. Something is broken, right?! We tested PUN 2 in early access and with our demos but of course, there can be bugs. When reporting issues in PUN 2, please make sure to tell us you're using PUN 2 already. Reply here or mail to: firstname.lastname@example.org. Release History (recent releases) v2.10 (26. April 2019) Fixed: Unity 2019 compatibility. Removed warnings about obsolete APIs. Code clean up to remove compiler warnings in Unity 2019. Fixed: PhotonTransformView does not interpolate between the first streamed data and subsequent to avoid the initial drift between the player's original position and the current position. Added: Nintendo Switch Authentication enum value. More about this on our doc page for Nintendo Switch development. Changed: GetGameList operation is not sent when filter is null or empty. This resulted in a server-side error and now GetGameList logs this case and returns false. Changed: IsConnectedAndReady is now also false for ClientState.DisconnectingFromGameserver, DisconnectingFromMasterserver and DisconnectingFromNameServer. Changed: InLobby property is now checking the State == JoinedLobby, which is analog to InRoom. Changed: InRoom property getter checks if CurrentRoom is not null. Changed: removed references to PUN1's removed PhotonNetwork.GetRoomList(). Changed: Renamed ClientState items which ended on "Gameserver" and "Masterserver" to using PascalCase "GameServer" and "MasterServer". The previous names are obsolete to ease upgrading this, if needed. Fixed: BroadcastPropsChangeToAll is applied correctly (it wasn't used properly, when false). Fixed: When in offline mode, OpSetPropertiesOfActor does not get called (it failed due to not being connected). Updated: To new library version 184.108.40.206 (26. April 2019 - rev5046). Note: EventData.Parameters is no longer guaranteed to be non-null! Events sent via RaiseEvent (the most common form) will have Code, Sender and CustomData but Parameters will be null. Internally, this means we can re-use some more memory. PUN covers this change for you but if you use the events more directly, you may notice. Chat Fixed: properly add local client's UserId to public channels' Subscribers list when applicable. v2.9 (26. March 2019) Fixed: Automatic level synchronization, which was affected by the callback change in v2.8.0. Now, as in 2.7 and earlier, the scene is loaded on join, before the OnJoinedRoom callback. Changed: The api reference for LevelLoadingProgress and LoadLevel. Fixed: Surplus call to Disconnect when the app quits but PUN is offline. This also means there is no OnDisconnected() callback in this case (which happened unintentionally). Internal: SetLevelInPropsIfSynced() is now called in NewSceneLoaded() under the condition that PUN was not causing the scene-load. So it's not called when the scene loaded via PhotonNetwork.LoadScene. Fixed: SetLevelInPropsIfSynced() now checks if the new value is not in the props yet and if so, it will set the property right away. Fixed: When using LoadLevel(), this will set the new sceneId as property right away (unless it didn't change). This should avoid delays on other clients loading the same scene. Changed: The condition when a async load is canceled. If at all, it only cancels a PUN-initiated loading, if the new sceneId does not refer to the scene in the properties. Fixed: PunCockpit script. Using the left side of the lobby panel, it now uses the default lobby (no name, type = default) for CreateRoom and JoinRandom. If you JoinLobby in one client and CreateRoom in another, the created room will also show up in the list (bottom right). v2.8 (15. March 2019) Changed: Unity 5.6.6f2 is now the minimum supported version. Older versions won't run in the most up to date MacOS anymore, so we decided to drop those. Added: VIVEPORT Authentication provider. See: https://www.photonengine.com/en-us/viveport and docs: https://doc.photonengine.com/en-us/...d-authentication/authentication/viveport-auth Changed: The cached "best region" is cleared whenever a region's pinging finishes. This fixes a potential issue when the BestRegion value is used before the pinging is done. Then, you end up with a wrong selection. Added: When connecting to a Master Server directly (likely a Photon Server / OnPremise) without a UserId, PUN will now set a GUID. This reflects the behaviour of the Photon Cloud and helps differentiate clients by a UserId in matchmaking. Changed: When connecting to a Master Server directly (likely a Photon Server / OnPremise) with WebSockets, PUN now automatically uses a compatible serialization protocol (GpBinaryV16). Changed: The callback OnRoomPropertiesUpdate is not called when/before entering a room. It was called whenever properties change, which is also the case when the Realtime API constructs the room (with properties). Wait for OnJoinedRoom and check properties the first time when that's called. Updated: Photon3Unity3d.dll library to 220.127.116.11, rev5023. v2.7 (13. February 2019) Fixed: Offline mode. Custom properties are now set properly. Renamed: PhotonNetwork.BackgroundTimeout is now PhotonNetwork.KeepAliveInBackground. Fixed: PhotonNetwork.KeepAliveInBackground now sets the ConnectionHandler.KeepAliveInBackground, which actually affects the background keep-alive. Fixed: A crash problem on Nintendo Switch. Setting a Thread.Name caused a crash in some Unity exports. We work around this by simply not naming internal threads. Updated: Photon3Unity3d.dll library to 18.104.22.168, rev4985. Photon Chat: Added: Client API for Max Subscribers and Publish Subscribers features inside public channels. v2.6 (25th January 2019) Fixed: Offline custom properties are now set even if ExpectedProperties is set, as there is only one source for setting properties when in offline mode. Fixed: Switching Offline mode off now properly cleans up room content. Fixed: Infinite for-loop when enabling all Interest Groups by using new byte as parameter for the SetInterestGroups function. Fixed: The PhotonView attribute AddComponentMenu could not have a shortcut (in 2018.3) for unknown reasons. It was causing compile errors in some cases, so the shortcut (&v) is gone. Fixed: Rpc list was not showing in the ServerSettings Inspector. Fixed: Inspector for ServerSettings no longer closes due to recompile. Added: Tooltips for all fields in the Photon Server Settings. Each entry is now at least somewhat explained. More in the docs. Changed: PhotonNetwork.WebRPC can set AuthCookie webflag, which is used for WebHooks. Changed: PhotonNetwork.CurrentLobby and LoadBalancingClient.CurrentLobby are now readonly. The lobby must be defined by joining one or via the parameter when creating rooms. As before: You don't have to join a lobby to do matchmaking via a lobby. Changed: SupportLogger now makes use of the new ServerIpAddress value in the PhotonPeer. Changed: Added a local timestamp to the SupportLogger: it now logs [Time.unscaledTime] in front of each log. Changed: SupportLogger will also log the "basics" when it got the RegionsList from the Name Server (and it now logs the NS IP-address). Changed: The log output when Join/Create failed. Now it also logs the State (which is the primary value for IsConnectedAndReady). Better for debugging. Changed: PhotonNetwork.time is now cached per frame (based on Unity's frameCount value). This applies the same time-value for the whole frame, no matter when Update() gets called on a specific object. This might avoid some judder when syncing objects. Changed: The property "timestamp" is obsolete (as name) in PhotonMessageInfo. There is now a SentServerTimestamp integer and a SentServerTime double. It makes sense to use the integer to calculate delta-times in milliseconds. Added: Callback OnDisconnected() to connection-exception handling for "Exception in Receive". Also for: "Max CCU Reached" (probably not used). Added: Note in reference doc, that "Exception" for receive is typical if you connect a local Photon on Windows but the server isn't running/available. Fixed: SetInterestGroup() for Offline mode. If offline, it can simply skip the call to OpChangeGroups and avoid some log spamming. Added: ServerSettings now let you open the dashboard directly for each types of ids, and let you open the whiteList region editor as well. Fixed: PhotonEditorUtils.IsPrefab() is fixed for 2018.3 onwards, it now takes in consideration both assets and prefab editing stage when checking. Changed: Setting PhotonNetwork.PrefabPool to null now logs a warning and default to the DefaultPool class. Fixed: Problems with "Best Region" selection on Nintendo Switch. Best Region now works, even if all available Photon Cloud regions need to be pinged. Internal: PingMono class now keeps one Socket instance until discarded. Internal: PingMono uses Socket.Poll() now, instead of .Available (which might also be the cause why this is Switch compatible now). Internal: PUN now sends PhotonView-updates via a re-used List<object>. A second list was added to the PhotonView, so they can be used alternating and without copying values before sending them. Changed: ExecuteRpc() to not always create argument- and argument-type-list. This is a minor optimization. Changed: ExecuteRpc() check of arguments versus a method's parameters. Changed: RPC() to re-use the event-content Hashtable (and clear it instead of re-creating it every time). Updated: Photon3Unity3d.dll library to rev4954. PUN Classic v1.94 (13. February 2019) Fixed: A crash problem on Nintendo Switch. Setting a Thread.Name caused a crash in some Unity exports. We work around this by simply not naming internal threads. Updated: Photon3Unity3d.dll library to 22.214.171.124, rev4985. PUN Classic v1.93 (17. January 2019) Fixed: Support for 2018.3 and newer prefab editing workflow. Fixed: SetInterestGroup() for Offline mode. If offline, it can simply skip the call to OpChangeGroups and avoid some log spamming. Fixed: RPG Movement Demo. It was all-black in the last version, it seems. Updated: To Photon3Unity3d.dll v126.96.36.199, which is the same as used in PUN 2 with several performance improvements. See plugins\release_history.txt. Added: PhotonPing classes for the Best Region feature. They are not part of the used dll anymore (see below). Updated: SocketWebTcp.cs to match the new photon dll. It's now only compatible with Unity 5.3 and up. Photon Chat: Added: Client API for Max Subscribers and Publish Subscribers features inside public channels. PUN Classic v1.92 (26. October 2018) Updated: Removed "UsePreciseTimer" option and made it the only way to maintain time. Fixed: Issue with TextField in GUIFriendFinding, which wasn't used correctly. Fixed: RoomOptions.CleanupCacheOnLeave not synchronizing properly, if a PUN Client joins a room, which has been created by another SDK Client (i.e. DotNet SDK). This resulted in objects not getting removed properly, after the client has left the room. Added: Reloading a level is not taken into consideration when PhotonNetowrk.automaticallySyncScene is turned on and will trigger a level reload on all client Updated: To Photon3Unity3d.dll v188.8.131.52, which contains a fix for the Runtime 4.x Mono. See plugins\release_history.txt. Release History All updates are detailed in the changelog.txt in the package. Download Asset Store Special thanks go to Jean, Vadim, Leepo, Hamza and Olli for their great work, feedback and support. Upcoming Support for more platforms, more useful components and lighter networking. Known Issues When you load a new scene, all instantiated GameObjects are destroyed only locally but not on the server. Anyone who joins the room later on still creates those GOs. To work around this, PhotonNetwork.Destroy your instantiated game objects before loading a new scene. Or use: PhotonNetwork.RemoveAllInstantiatedObjects(player). Changing the group of a PhotonView is only done locally and not synced. If you Instantiate a new object in a group that wasn't subscribed first, then the local client won't create the GameObject (it is culled by Interest Group). When you use multiple scenes, the viewIDs of PhotonViews in those scenes will always start at 1. Edit the PunSceneSettingsFile in your project to enter a minimum ViewID per scene if needed. Feedback is welcome! Just reply here. This post will be edited over time with more info, updates, etc.