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.14 (9. August 2019) Updated: To using Unity 2017.4.7 as lowest supported version. The Asset Store no longer supports uploading packets for older Unity versions. A few variables are now public, as they were not accessible otherwise due to assembly definitions. Changed: The callbacks to OnDisconnected(reason). On timeout or exception, there is now only one callback which happens after the client/peer is actually disconnected. The peer's status changes (timeout, etc.) are used to identify the reason but don't cause a callback on their own. Previously, you could run into more than one OnDisconnected call and fail to reconnect in the first one. Changed: There are now fewer calls of OnDisconnected(). Example: A timeout disconnect caused two calls because signalled the timeout and the second signalled when the client locally finished disconnecting. Now, the DisconnectCause stores the reason and there is only one callback. Changed: Internal use of DisconnectCause. It's now set in LBC.Disconnect() and by errors from the Peer. It's reset to "None" before calls to Peer.Connect(). Removed: DisconnectCause enum values that were obsolete already. DisconnectByServerUserLimit is now MaxCcuReached. TimeoutDisconnect is now ClientTimeout. DisconnectByServer is now ServerTimeout. Changed: SupportLogger. Traffic stats are enabled by default. The PhotonHandler no longer has to enable this. Added: Min/max ping to logged statistics. SupportLogger.TrackValues is invoked to keep track of min/max ping for each connection. Fixed: Statistics logging is started on Connect and stopped OnDisconnected(). Added: AssemblyDefinition for the Editor scripts of Demos (which have been one big assembly, including the Editor scripts). Fixed: Basic Tutorial Player UI hiding system when player is not visible. Added: Check to Connect methods to not connect, if the app quits. This was freezing of the Editor in some cases. Changed: Callback registration. Changed: All callback target changes are now queued in one queue and executed in order. This avoids cases where our implementation defined if a callback got added or removed, when a target got added and removed. Changed: Duplicate addition and removal is now prevented. Changed: The callback containers now know and use the LoadBalancingClient to update the targets. This means they don't need lists for additions and removals anymore. Changed: Events will now also update the callback targets before executing the event callback. Changed: WebRpcCallbacksContainer is now also a List<i> like the other containers. This is simpler to maintain. The only "custom" callback implementation is that for events. This was an event delegate before and remains one. No change for this. Changed: PhotonViewIdHandler to keep assigned viewIDs if they don't clash. This avoids some issues when editing projects.The workflow now applies the minimum scene view ID for PhotonViews for multiple open scenes. Changed: Editor usage of PUN. Changed: PhotonEditor no longer uses the Editor update loop. It updates less frequently and more to the point with specific events. Changed: The PhotonEditor is not using PhotonNetwork.PhotonServerSettings anymore, which could cause a freeze of the Editor. Fixed: The PhotonEditor could fail to load the PhotonServerSettings when loading a project without "library" folder in Editor 2019. This showed as a lost app id, even though the project had one earlier. Fixed: UpdateRpcList failed to load any "user assemblies", due to now using AssemblyDefinitions. This means RPCs were sent as full name, which is wasteful (but not an error as such). Changed: UpdateRpcList with LINQ. This is less code, easier maintain and read. Changed: The "on compile" disconnect is done much faster now and hopefully avoids some issues. Internal: Removed PhotonNetwork.photonMono. As the Handler is supposed to be a singleton with Instance, PUN should use that. Fixed: Two layout issues in the PhotonView Inspector GUI (for very lean windows). Added: Option to dispatch incoming messages, even if Time.timeScale = 0: PhotonNetwork.MinimalTimeScaleToDispatchInFixedUpdate. It defaults to not being used. Changed: Execution order for disconnect on quit. As OnApplicationQuit is followed by OnDisable, PUN now disconnects in OnDisable, if OnApplicationQuit was called previously. This means that you can now send a final message in OnApplicationQuit. It's not guaranteed to arrive anywhere, as the message won't be repeated on loss. Changed: WebRpcResponse.ReturnCode -> ResultCode and WebRpcResponse.DebugMessage -> Message. Added: Now showing current best region and its ping from Players' Prefs in ServerSettings. Added: ServerSettings now lets you edit Rpc List in Inspector, shows the rpc hash as Hex string and let ypu copy it in the OS Clipboard. Fixed: Textures needed for editor interfaces now search for the PUN folder instead of assuming a hardcoded path. Updated: To new library version v188.8.131.52. v2.13 (25. June 2019) Added: Options for OpFindFriends to filter which rooms should be returned by the server. The default is the same as before but now the friend list may exclude rooms which are not yet on the game server, invisible, closed (or any combination). Fixed: Typos and null checks in PhotonNetwork class. Fixed: SerializationProtocol selection for WebGL. Fixed: Missing IWebRpcCallback interface reference added to MonoBehaviourPunCallbacks. Added: PhotonNetwork.AllocateViewID(bool sceneObject), which can be used to just get a viewID that is then assigned manually. Updated: Improved wording for warning on missing photonViews during serialization. Changed: The library now has a changes-realtime.txt file instead of a release_history.txt. The plan is to separate library and Realtime API updates from those of PUN and other packages. Also check out changes-realtime.txt and changes-library.txt. Updated: PUN Cockpit. It will now rejoin instead of join if needed. Updated: To new library version 184.108.40.206. This fixes an issue with a ThreadAbortException thrown on Android (with specific Unity build settings) and improves connection stability in cases where the ping goes up temporarily. Chat Added: ChatClient.TryGetPrivateChannelByUser. v2.12 (6. May 2019) Fixed: Breaking change of EventData. The properties Sender and CustomData are back and they keys (in the event Parameters) can now be configured at runtime (if needed). Updated: To new library version 220.127.116.11 (6. May 2019 - rev5088). v2.11 (3. May 2019) Fixed: EventData usage. PUN v2.10 had a bug in Ownership Transfer calls and some events. Fixed: ClientState.ConnectedToMasterserver did not have the same value as ConnectedToMasterServer (and no longer got used at all). This affects only rare cases where the enum is directly used (PUN was updated). Changed: Account registration scripts to use Unity's built-in JSON parsing. Now, PUN no longer incldues the NewtonSoft Json dll (which should avoid the occasional clash of dlls). Updated: To new library version 18.104.22.168 (3. May 2019 - rev5086). Changed: EventData was changed in the Photon3Unity3d.dll again. Now it does not have a Sender or CustomData property anymore as those were not workign for Chat (and misleading). Instead, those are fetched from the Parameters of an event (each API provides accessor extensions). Added: PhotonPeer.ReuseEventInstance as option to use a single EventData instance for all incoming events. This reduces memory garbage. The drawback is: An event provided via OnEvent(EventData photonEvent) is invalidated right after the callback finished. That event's content will get modified. Typically this is not a problem as events are rarely cached. Chat Fixed: Properly add local client's UserId to public channels' Subscribers list when applicable. 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 22.214.171.124 (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. 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, 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.