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

  1. Right-click in Project window
  2. Select Create → ElderWorldStudio/Friend List → Friend Manager Settings
  3. A new asset will be created in the selected folder

Method 2: Using the Editor Window

  1. Open Window → ElderWorldStudio/Friend List
  2. Click on Settings tab
  3. Click Create New Settings

Method 3: Duplicate Existing

The quickest way to create environment-specific settings is to duplicate the default:

  1. Find Resources/FriendManagerSettings.asset
  2. Right-click → Duplicate
  3. Rename (e.g., FriendManagerSettings_Development.asset)
  4. Configure for your target environment

Backend Configuration

Backend Type (BackendType)

Select which networking solution your game uses:

ValueDescription
PhotonPUNPhoton Unity Networking (PUN Classic)
PhotonFusionPhoton Fusion (real-time)
MirrorMirror Networking
UnityNetcodeUnity Netcode for GameObjects
FishNetFishNet Networking
CustomYour own backend server

Use Native Implementation (UseNativeImplementation)

ValueBehaviorUse When
trueUse the network's built-in friends systemYour game only uses one network type
falseUse the custom ElderWorldStudio serverYou need cross-network friends or server moderation
Note: Native implementation is only available for Photon PUN and Photon Fusion. All other backends require the custom server option.

Server Configuration (Custom Backend Only)

These fields only apply when Backend Type is set to Custom and Use Native Implementation is false.

FieldTypeDefaultDescription
UseWebSocketbooltrueEnable WebSocket for real-time updates (vs HTTP polling)
ServerUrlstringhttps://api.ElderWorldStudio.com/friendsREST API base URL
WebSocketUrlstringwss://api.ElderWorldStudio.com/friends/wsWebSocket connection URL
PollingIntervalfloat5Seconds 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:

FieldTypeDefaultDescription
MaxFriendsint100Maximum friends a user can have
MaxBlockedUsersint100Maximum blocked users allowed
Important: These are client-side limits. Your server should also enforce these limits for security.

Persistence Configuration

Control whether friend and block lists persist between game sessions:

FieldTypeDefaultDescription
PersistFriendListbooltrueSave friends to PlayerPrefs between sessions
PersistBlockListbooltrueSave blocked users between sessions

When enabled, lists are cached locally and loaded on initialization, reducing server calls for returning users.

Refresh Configuration

FieldTypeDefaultDescription
RefreshIntervalfloat30Seconds between automatic friend list refreshes

Set to 0 to disable automatic refresh (you'll need to call RefreshFriendList() manually).

Recommendation: 20-60 seconds is a good balance between freshness and server load. Lower values for competitive games where presence matters.

Managing Multiple Environments

For projects with multiple environments (development, staging, production), create separate settings assets:

  1. FriendManagerSettings_Dev.asset → Points to localhost dev server
  2. FriendManagerSettings_Staging.asset → Points to staging server
  3. FriendManagerSettings_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