Photon Fusion Integration
Photon Fusion is Photon's real-time multiplayer solution with state synchronization. Universal Friend List supports Fusion through both native and custom server implementations.
Prerequisites
Photon Fusion Requirements
- Photon Fusion package installed
- A Photon Fusion App ID configured
- Unity 2021.3 or newer
Fusion setup is similar to PUN - download from the Asset Store and configure your App ID.
Configuration
Native Fusion Friends
To use Fusion's native friends:
- Set Backend Type to
PhotonFusion - Set Use Native Implementation to
true - Fusion's player ID will be used as the user identifier
Custom Server with Fusion
To use the custom server:
- Set Backend Type to
PhotonFusion - Set Use Native Implementation to
false - Configure server URLs (see Server Setup)
- The Fusion Player ID will be mapped to the server's user ID
Example: Simple Fusion Connection
See Scripts/Examples/NetworkConnections/SimplePhotonFusionConnection.cs:
using Fusion;
using Fusion.Sockets;
using UnityEngine;
public class SimplePhotonFusionConnection : MonoBehaviour, INetworkRunnerCallbacks
{
private NetworkRunner _runner;
public async void StartGame() {
_runner = gameObject.AddComponent<NetworkRunner>();
_runner.AddCallbacks(this);
var startArgs = new StartGameArgs() {
GameMode = GameMode.AutoHostOrClient,
SessionName = "my_session"
};
await _runner.StartGame(startArgs);
}
public void OnConnectedToServer() {
Debug.Log("Connected to Fusion server");
// FriendManager will use Fusion player ID
}
}