FriendManagerSettings
Scripts/Managers/FriendManagerSettings.cs
FriendManagerSettings is a ScriptableObject that stores all configuration options for the Universal Friend List system. By using a ScriptableObject, settings can be shared across scenes, easily switched between builds, and version controlled alongside other project assets.
Creating a Settings Asset
Method 1: Using the Unity Menu
- Right-click in Project window
- Select Create → ElderWorldStudio/Friend List → Friend Manager Settings
- A new asset will be created in the selected folder
Method 2: Using the Editor Window
- Open Window → ElderWorldStudio/Friend List
- Click on Settings tab
- Click Create New Settings
Method 3: Duplicate Existing
The quickest way to create environment-specific settings is to duplicate the default:
- Find
Resources/FriendManagerSettings.asset - Right-click → Duplicate
- Rename (e.g.,
FriendManagerSettings_Development.asset) - Configure for your target environment
Backend Configuration
Backend Type (BackendType)
Select which networking solution your game uses:
| Value | Description |
|---|---|
PhotonPUN | Photon Unity Networking (PUN Classic) |
PhotonFusion | Photon Fusion (real-time) |
Mirror | Mirror Networking |
UnityNetcode | Unity Netcode for GameObjects |
FishNet | FishNet Networking |
Custom | Your own backend server |
Use Native Implementation (UseNativeImplementation)
| Value | Behavior | Use When |
|---|---|---|
true | Use the network's built-in friends system | Your game only uses one network type |
false | Use the custom ElderWorldStudio server | You need cross-network friends or server moderation |
Server Configuration (Custom Backend Only)
These fields only apply when Backend Type is set to Custom and Use Native Implementation is false.
| Field | Type | Default | Description |
|---|---|---|---|
UseWebSocket | bool | true | Enable WebSocket for real-time updates (vs HTTP polling) |
ServerUrl | string | https://api.ElderWorldStudio.com/friends | REST API base URL |
WebSocketUrl | string | wss://api.ElderWorldStudio.com/friends/ws | WebSocket connection URL |
PollingInterval | float | 5 | Seconds between HTTP polls (when WebSocket disabled) |
Local Development URLs
When developing with the included server:
- Node.js Server: ServerUrl =
http://localhost:3001, WebSocketUrl =ws://localhost:3001/ws - PHP Server: ServerUrl =
http://localhost:3000(WebSocket disabled)
Limit Configuration
Client-side limits that help prevent malicious use and manage memory:
| Field | Type | Default | Description |
|---|---|---|---|
MaxFriends | int | 100 | Maximum friends a user can have |
MaxBlockedUsers | int | 100 | Maximum blocked users allowed |
Persistence Configuration
Control whether friend and block lists persist between game sessions:
| Field | Type | Default | Description |
|---|---|---|---|
PersistFriendList | bool | true | Save friends to PlayerPrefs between sessions |
PersistBlockList | bool | true | Save blocked users between sessions |
When enabled, lists are cached locally and loaded on initialization, reducing server calls for returning users.
Refresh Configuration
| Field | Type | Default | Description |
|---|---|---|---|
RefreshInterval | float | 30 | Seconds between automatic friend list refreshes |
Set to 0 to disable automatic refresh (you'll need to call RefreshFriendList() manually).
Managing Multiple Environments
For projects with multiple environments (development, staging, production), create separate settings assets:
FriendManagerSettings_Dev.asset→ Points to localhost dev serverFriendManagerSettings_Staging.asset→ Points to staging serverFriendManagerSettings_Prod.asset→ Points to production server
Switch between them by assigning different assets to FriendManagerInitializer based on your build configuration or scene.
// Switch settings based on build
#if DEVELOPMENT
initializer.Settings = devSettings;
#elif STAGING
initializer.Settings = stagingSettings;
#else
initializer.Settings = prodSettings;
#endif