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 2017.4.7 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? We strongly recommend to upgrade from PUN Classic to PUN 2. The migration is not extremely hard and by now, PUN 2 got so many improvements that you would miss out if you didn't upgrade. Existing subscriptions (e.g. of a previously purchased PUN Classic 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). Reply here or mail to: email@example.com. Release History (recent releases) v2.30 (13. April 2021) Changed: When the PhotonView.ControllerActorNumber should be set to 0, it now sets the backing field to the Master Client's actorNumber instead. This prevents misunderstandings when updates are sent with the Master Client's actual actorNumber Changed: Setting the PhotonView.ControllerActorNumber will now refresh the Controller in all cases. This makes sure that (e.g.) scene objects get a Controller value OnJoinedRoom (they might exist before a room is joined). Updated: EventSystemSpawner to log an error and pause the execution, if only the new input system is being used. The PUN demos are not compatible with it unless you set Active Input Handling to "Both". Note: Only the PUN demos are incompatible with the new input system. PUN itself is not affected. As the demos are in separate folders, you can easily delete all of them and use the new input system in your project. Updated: Realtime API to 220.127.116.11, preventing several error cases. v2.29 (15. March 2021) Updated: Minimum supported Unity version to 2018.4.x. We develop PUN 2 in Unity 2018.4.22 from now on. Also the language compatibility level '.Net Standard 2.0' is now being expected. Updated: Export settings for the dlls in Assets\PhotonLibs. All platforms will use .Net Standard 2.0, except the UWP export with .Net Runtime (which uses Metro with a placeholder being the lib in PhotonLibs\). Removed: Setting of protocol 1.6 when connecting directly to a Master Server. This was a workaround for older Photon Server SDKs. Note: If you host Photon yourself, you can set the LoadBalancingClient.SerializationProtocol to SerializationProtocol.GpBinaryV16, before you connect. Fixed: The PhotonView's "Find" button was not saving the observed components in scenes, which meant the script wasn't called at runtime. Added: IPunOwnershipCallbacks.OnOwnershipTransferFailed. This helps react when an Ownership Transfer request failed (due to earlier changes). This might mean you have to implement OnOwnershipTransferFailed in some scripts. Changed: PhotonView OwnerActorNr and ControllerActorNr to make use of the new Room.GetPlayer() option (to get the Master Client instance if the owner/controller is set to 0). Updated: Library to 18.104.22.168. v2.28.3 (03. March 2021) Fixed: PhotonView.AmOwner was not updated. v2.28.2 (03. March 2021) Fixed: A potential issue with the execution order of the PhotonView component. It now sets it's own execution order to -16000 to get initialized before other scripts (especially on scene loading). Changed: Conditionals and logging output for Xbox builds. In the Editor, it's impossible to get a token, so PUN should not enforce this. Changed: PhotonView.ControllerActorNr will make sure the PhotonNetwork.LocalPlayer is not null when accessing the actorNumber through that. Changed: Instantiate will set PhotonView lastOnSerializeDataSent and lastOnSerializeDataReceived to null (which keeps instantiation for reused objects cleaner). v2.28 (23. February 2021) Changed: PhotonView code to cache Owner and Controller, as well as storing the sceneViewId for objects which load with the scene. This is a bigger change and complex, so it may break some projects, despite the testing! Mail us, if you run into issues with ViewIDs, Ownership, etc: firstname.lastname@example.org. Added: DisconnectCause DnsExceptionOnConnect and ServerAddressInvalid (which might be renamed). Changed: Inspector to trim the values of AppId fields. Fixed: Likely fixes issue with Resources.Load failing to find prefabs in latest Unity versions. This is more of a workaround for Unity problems/changes. Changed: The re-usable list of PhotonViews in RemoveInstantiatedGO() is now cleared when it's no longer needed to avoid lingering PhotonView references (memory leaking). Added: OfflineMode to StaticReset(). So fast play mode (without domain reload) will not keep the client in offline mode. Changed: PhotonNetwork.Server for offline mode. It will now report the GameServer when an offlineroom is existing. Added: In OfflineMode, PhotonNetwork.LeaveRoom() will now also call the OnConnectedToMaster() callback. As the OfflineMode changes values immediately, the timing of callbacks might be slightly different than in online mode. Joining a room offline is instantaneous. Updated: Library to v22.214.171.124. which includes using the new Native Encryptor API (v2), a fix for NonAllocDictionary.Remove() and new StatusCode entries for DNS and IP issues. v2.27 (12. January 2021) Removed: "Simple" networking. Due to the progress on an upcoming networkin solution (Fusion), we will keep this set of components an external addon in maintenance mode (supported but not improved/extended). Please remove the folders Photon\PhotonUtilities and Photon\Simple. Updated: The Realtime API and Photon3Unity3d.dll to v126.96.36.199. This has a fix for unsequenced commands and improved ToString() support for the classes we added for the non-alloc workflow. v2.26 (09. December) Fixed: Possible IndexOutOfRangeException causing import issues when cached best region summary is not in expected format. Changed: Wizard will load Realtime AppId from settings, if present. This should avoid surplus registrations. Changed: PhotonEditor will not call RegisterByEmail, if a request is pending some result. For that, the serviceClient is now a class variable and not a local one. Added: Extra check to avoid sending useless (empty array payload) OwnershipUpdate event. Updated: The Realtime API and Photon3Unity3d.dll (v188.8.131.52) with smaller improvements and changes. Check the respective changelogs. v2.24 (26. November 2020) Added: PhotonTransformView.UseLocal. It defaults to true for any new PhotonTransformView but allows to get the "old" behaviour with world position and rotation data being synced. Fixed: Inspector UI for PhotonTransformView and PhotonAnimatorView. Warning box for using triggers broke horizonal bounds, causing horizontal scrollbars on inspector. Switched to standard helpbox. Changed: Drastically lowered the MaxDatagrams value, to not send too much in one frame. Changed: Default sendFrequency to 33ms. PUN will send in more frames but less datagrams in each. Changed: SendRate does not affect the SerializationRate value anymore. Also, SerializationRate can be set independent from the SendRate. Updated: Documentation about SerializationRate and SendRate. This now explains more details about sending. Realtime API: Fixed: It was possible to trigger multiple calls of Authenticate by calling ConnectToRegionMaster(region) multiple times while being connected to the Name Server. Changed: AuthenticationValues.ToString() to expose less data while showing which values are set. Photon dll v184.108.40.206: Fixed: PhotonClientWebSocket handling of messages > MTU. Incoming messages may be incomplete and are now reassembled. Before the fix, common result was that deserialization failed with incorrect / incomplete data. Added: ExitGames.Client.Photon.Hashtable Add() and Remove() for byte keys. This makes sure ht.Add(0, obj) and ht.Remove(0) match how the access via ht works. v2.23 (17. November 2020) Changed: CustomTypes are now split into CustomTypes and CustomTypesUnity. The latter is part of the Realtime API and registers automatically for Unity projects (in LoadBalancingClient constructor). This only changes internals for PUN. The Player class is only a de/serializable type in PUN. Changed: DebugLog info in case an RPC was not found. Making it clear that RPCs should return null or an IEnumerator (if you enable RunRpcCoroutines). Changed: Creation of the locally used EventData instance. The Parameters are now readonly and non-null. Updated: Registration wizard to avoid multiple registration calls. Fixed: Callback registration updates when the owner changes (PhotonView.SetOwnerInternal()). Changed: PhotonServerSettings label for Appid of PUN. Was labelled as "Realtime" but there is a "PUN" type of appids which should be used. Changed: Various places in PUN to re-use boxed bytes (instead of causing boxing in those places). Added: Handing for compile defines PUN_DISPATCH_IN_FIXEDUPDATE and PUN_DISPATCH_IN_LATEUPDATE. It locks Dispatch calls to the respective monobehaviour methods (and timing). Use one or the other. Changed: Depending on PhotonNetwork.MinimalTimeScaleToDispatchInFixedUpdate and the Time.timeScale, PUN will dispatch incoming messages in FixedUpdate or in LateUpdate. Before it potentially was running in both MonoBehaviour callbacks. Changed: Description of PhotonNetwork.MinimalTimeScaleToDispatchInFixedUpdate to reflect and explain the change above. Changed: Loading and creation of the PhotonServerSettings file. We got several reports of errors with this but could not properly reproduce them. Several safeguards were added and in worst case, you might end up with two PhotonServerSettings files (if you had an old one). Added: BestRegion now checks if the operation GetRegions was successful. If it returned an error, it skips pinging (and the client will get disconnected anyways). Updated: The Realtime API and Photon3Unity3d.dll (v220.127.116.11) with lots of improvements and changes. Check the respective changelogs. 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 We are working on better sync components. This is a separate package, called SNS 2 and can already be downloaded. 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.