Universal Friend List

Production-oriented documentation for friends, requests, blocking, online presence, rooms, and invitations in multiplayer Unity projects. Supports native provider APIs where available and a ElderWorldStudio-compatible Node.js (WebSocket + REST) or PHP (REST) stack for full control.

Unity 2021.3 LTS+ Photon PUN / Fusion Mirror · NGO · FishNet Custom backend Node.js · PHP
Network backends
6
Realtime
WebSocket
Fallback
HTTP polling
Scope
Client + server sample

Package contents

Everything ships under ElderWorldStudio/FriendList/. Sample servers live in .Server (hidden in Unity by default; still included for deployment).

ElderWorldStudio/FriendList/ ├── Scenes/ Demo.unity ├── Scripts/ Runtime C# (managers, networking, UI, models, game types) ├── Prefabs/ UI and list items ├── Resources/ FriendManagerSettings, ServerConfig assets ├── Content/ UI textures and assets ├── Documentation/ This HTML manual └── .Server/ websocket (Node) · php (REST) · sample DB

Quick start

  1. Open ElderWorldStudio/FriendList/Scenes/Demo.unity.
  2. Select Resources/FriendManagerSettings (or the assigned settings asset on the initializer).
  3. Set Backend Type and Use Native Implementation to match your project.
  4. For the ElderWorldStudio custom server: set backend to Custom, configure Use WebSocket, Server URL, and WebSocket URL (see defaults in FriendManagerSettings).
  5. Enter Play Mode and verify list load, presence, requests, and invites.
Local realtime: Run the Node server from .Server/websocket and point WebSocket to ws://localhost:3001/ws (see server section).

Quick start video

Embed or link your quick start walkthrough here (YouTube / Vimeo / self-hosted).

Video tutorials

Installation & import
Friends, requests, invites
Backend integration & scaling

Installation

Prerequisites

  • At least one networking stack: Photon PUN 2 or Fusion, Mirror, Netcode for GameObjects, FishNet, or a custom auth/runtime for Custom.
  • Project compiles cleanly before importing this asset.

Import

  1. Import the package into your project.
  2. Wait for script compilation to finish.
  3. Open the demo scene and confirm references (FriendManager, UI, settings).
Compile errors: Often caused by missing networking packages or scripting define symbols for optional SDKs. Install the SDK you need or wrap code with the same defines the asset uses.

Unity setup

1) FriendManagerSettings (ScriptableObject)

Create via Assets → Create → ElderWorldStudio → Friend List → Friend Manager Settings. Defaults use ElderWorldStudio-style URLs; override for your deployment.

FieldTypeDefault (code)Purpose
BackendTypeNetworkBackendTypePhotonPUNSelects integration path and identity source.
UseNativeImplementationbooltrueUse provider-native friends when available; turn off for ElderWorldStudio Node/PHP.
PersistFriendList / PersistBlockListbooltruePersistence between sessions.
RefreshIntervalfloat30List refresh when not using push paths.
MaxFriends / MaxBlockedUsersint100Client-side caps aligned with server rules.
UseWebSocketbooltruetrue = Node (WS + REST); false = PHP REST only.
ServerUrlstringhttps://api.ElderWorldStudio.com/friendsREST base when polling or derived from WS host.
WebSocketUrlstringwss://api.ElderWorldStudio.com/friends/wsWebSocket endpoint for realtime.
PollingIntervalfloat5HTTP polling interval when WebSocket is off.

2) FriendManagerInitializer

FieldNotes
SettingsReference to FriendManagerSettings (required).
InitializeOnStartIf false, call Initialize() manually after login.
UserIdOptional override for custom auth flows.

3) FriendManager

Core runtime component: friends, requests, blocking, game-type hooks, and UnityEvents for UI. Pair with UI prefabs and your canvas.

Script inventory

Every runtime and editor script included in the package (search above to filter this page).

PathRole
Scripts/Managers/FriendManager.csMain friend manager, events, persistence keys, game-type routing.
Scripts/Managers/FriendManagerSettings.csScriptableObject settings.
Scripts/Managers/FriendManagerInitializer.csWires backend implementation and user id.
Scripts/Abstractions/INetworkFriendSystem.csNetwork friend API contract.
Scripts/Abstractions/IFriendManager.csFriend manager interface.
Scripts/Abstractions/IGameTypeHandler.csGame-type handler contract.
Scripts/Abstractions/BaseGameTypeHandler.csBase for game-type handlers.
Scripts/Abstractions/NetworkBackendType.csPhotonPUN, PhotonFusion, Mirror, UnityNetcode, FishNet, Custom.
Scripts/Abstractions/IServerClient.csServer client abstraction.
Scripts/Networking/BaseNetworkFriendSystem.csShared network friend logic.
Scripts/Networking/BaseCustomFriendSystem.csCustom / HTTP-WS client stack.
Scripts/Networking/CustomBackendFriendSystem.csCustom backend wiring.
Scripts/Networking/Photon/PhotonPunNativeFriendSystem.csPUN native.
Scripts/Networking/Photon/PhotonPunCustomFriendSystem.csPUN + ElderWorldStudio server.
Scripts/Networking/Photon/PhotonFusionNativeFriendSystem.csFusion native.
Scripts/Networking/Photon/PhotonFusionCustomFriendSystem.csFusion + ElderWorldStudio server.
Scripts/Networking/Mirror/MirrorCustomFriendSystem.csMirror + ElderWorldStudio server.
Scripts/Networking/Unity/UnityNetcodeNativeFriendSystem.csNGO native path.
Scripts/Networking/Unity/UnityNetcodeCustomFriendSystem.csNGO + ElderWorldStudio server.
Scripts/Networking/FishNet/FishNetNativeFriendSystem.csFishNet native path.
Scripts/Networking/FishNet/FishNetCustomFriendSystem.csFishNet + ElderWorldStudio server.
Scripts/Networking/Server/ElderWorldStudioServerClient.csHTTP client to ElderWorldStudio-compatible API.
Scripts/Networking/Server/ElderWorldStudioWebSocketClient.csWebSocket client.
Scripts/Networking/Server/ElderWorldStudioServerConfig.csServer config asset / runtime config.
Scripts/Networking/Server/ElderWorldStudioAuthHandler.csAuth helper.
Scripts/Networking/Server/ElderWorldStudioLogger.csLogging helper.
Scripts/Networking/Server/ElderWorldStudioErrorHandler.csError handling helper.
Scripts/Networking/Server/ServerDTOs.csDTOs for server payloads.
Scripts/GameTypes/GameTypeManager.csRegisters and selects game-type handlers.
Scripts/GameTypes/GameTypeFactory.csFactory for game types.
Scripts/GameTypes/GameTypeSettings.csShared settings base.
Scripts/GameTypes/RoomBasedGameTypeHandler.csRoom-based invitations / joins.
Scripts/GameTypes/OpenWorldGameTypeHandler.csOpen-world style behavior.
Scripts/GameTypes/Examples/RoomBasedGameTypeSettings.csExample room settings.
Scripts/GameTypes/Examples/OpenWorldGameTypeSettings.csExample open-world settings.
Scripts/Models/Friend.csFriend model.
Scripts/Models/FriendRequest.csFriend request model.
Scripts/Models/FriendRequestStatus.csRequest status enum.
Scripts/Models/FriendStatus.csPresence / status enum.
Scripts/Models/FriendInvitation.csInvitation model.
Scripts/Models/InvitationStatus.csInvitation status enum.
Scripts/Models/RoomInfo.csRoom metadata.
Scripts/Models/BlockEntry.csBlock list entry.
Scripts/UI/FriendListUI.csMain friend list UI controller.
Scripts/UI/FriendListItemUI.csFriend row.
Scripts/UI/FriendRequestItemUI.csRequest row.
Scripts/UI/FriendRequestsUI.csRequests panel logic.
Scripts/UI/AddFriendUI.csAdd-friend UI.
Scripts/Examples/SimpleCustomConnection.csExample custom connection.
Scripts/Examples/NetworkConnections/SimplePun2Connection.csPUN example.
Scripts/Examples/NetworkConnections/SimplePhotonFusionConnection.csFusion example.
Scripts/Examples/NetworkConnections/SimpleMirrorConnection.csMirror example.
Scripts/Examples/NetworkConnections/SimpleUnityNetcodeConnection.csNGO example.
Scripts/Examples/NetworkConnections/SimpleFishNetConnection.csFishNet example.
Scripts/Editor/FriendManagerSettingsInspector.csCustom inspector for settings.
Scripts/Editor/FriendManagerInitializerInspector.csInitializer inspector.
Scripts/Editor/FriendListEditorWindow.csEditor window.
Scripts/Editor/FriendListQuickSetup.csQuick setup utilities.
Scripts/Editor/FriendListSetupWizard.csSetup wizard.
Scripts/Editor/FriendListUIGenerator.csUI generation.
Scripts/Editor/FriendListItemGenerator.csItem generation.
Scripts/Editor/NetworkBackendValidator.csBackend validation.

Prefabs & content

AssetNotes
Prefabs/FriendListUI.prefabMain social panel shell.
Prefabs/FriendListItem.prefabFriend row (alternate naming: see also Friend List Item.prefab).
Prefabs/Friend List Item.prefabSpaced-name duplicate style prefab in package.
Prefabs/FriendRequestItem.prefabIncoming/outgoing request row.
Prefabs/Friend Request Item.prefabSpaced-name variant.
Prefabs/InvitationItem.prefabInvitation row.
Prefabs/BlockedUserItem.prefabBlocked user row.
Content/UI/Icons and UI images used by samples.
Resources/FriendManagerSettings.assetSample settings (adjust or duplicate per environment).
Resources/ServerConfig.assetServer configuration asset.

Editor tools

  • FriendListEditorWindow — centralized editor entry for friend-list tools.
  • FriendListSetupWizard / FriendListQuickSetup — guided or fast scene wiring.
  • FriendListUIGenerator / FriendListItemGenerator — generate UI hierarchy or items to match your canvas.
  • FriendManagerSettingsInspector / FriendManagerInitializerInspector — improved inspectors for core assets.
  • NetworkBackendValidator — validates backend configuration in the editor.

Open tools from the Unity menu where the package registers them (ElderWorldStudio / Friend List), or use the Friend List editor window if present in your menu layout.

Implementation comparison

ModeData sourceRealtimeBest for
NativeProvider friend APIsProvider-dependentFastest integration inside one ecosystem.
Photon PUN / Fusion nativePhoton servicesStrongPhoton-first titles.
Custom (ElderWorldStudio server)Node or PHP + your authHigh with WebSocketCross-stack consistency, moderation, custom rules.
Mirror / NGO / FishNet + customElderWorldStudio-compatible APIHigh with WebSocketDedicated servers and bespoke gameplay.
Guidance: Prefer native for prototypes; use ElderWorldStudio Node/PHP when you need one social graph across multiple clients or full server authority.

Unity components

FriendManager

Scripts/Managers/FriendManager.cs — implements IFriendManager; exposes UnityEvents for inspector wiring.

Serialized configuration

FieldDescription
_backendTypeNetworkBackendType selector.
_useNativeImplementationNative vs ElderWorldStudio custom server.
_persistFriendList / _persistBlockListLocal persistence.
_refreshIntervalPolling interval for non-push paths.
_maxFriends / _maxBlockedUsersLimits.
_defaultGameTypeRoom-based vs open-world style routing.
_autoInitializeGameTypeAuto-bind game-type handler.

UnityEvents (inspector)

UnityEventPayloadWhen
_onFriendListUpdatedList<Friend>Friend list refreshed.
_onFriendRequestReceivedFriendRequestNew incoming request.
_onFriendRequestAcceptedFriendRequestRequest accepted.
_onFriendRequestRejectedFriendRequestRequest rejected.
_onFriendRequestCancelledFriendRequestRequest cancelled.
_onFriendStatusChangedFriend, FriendStatusPresence changed.
_onFriendAdded / _onFriendRemovedFriendFriend added or removed.
_onUserBlockedBlockEntryUser blocked.
_onUserUnblockedstring (user id)User unblocked.
_onInvitationReceivedFriendInvitationInvitation received.
Screenshot: FriendManager inspector

FriendManagerSettings

Scripts/Managers/FriendManagerSettings.cs — same fields as listed in Unity setup; shared across scenes via reference.

Screenshot: FriendManagerSettings asset

FriendManagerInitializer

Scripts/Managers/FriendManagerInitializer.csInitialize(), CreateNetworkSystem(), GetUserId() (see inspector fields above).

Game types

GameTypeManager, RoomBasedGameTypeHandler, OpenWorldGameTypeHandler, and example settings under Scripts/GameTypes/ tailor invitations and room joins to your game structure.

UI scripts

FriendListUI, FriendListItemUI, FriendRequestItemUI, FriendRequestsUI, AddFriendUI — bind to FriendManager and prefabs listed above.

FriendListUI
List / request rows

INetworkFriendSystem API

Implemented per backend (native or custom). Common operations:

MemberSummary
Properties: BackendType, IsUsingNativeImplementation, IsConnectedState.
Events: list updated, request received, requests updated, status changed, invitation receivedMirror server events into C#.
Initialize(string userId)Start session for current user.
RefreshFriendList() / RefreshFriendRequests()Pull latest data.
SendFriendRequest, AcceptFriendRequest, RejectFriendRequest, CancelFriendRequestRequest lifecycle.
RemoveFriendUnfriend.
BlockUser / UnblockUserBlocking.
GetFriendRoomInfo, JoinFriendRoom, InviteFriendRooms and invites (RoomInfo).

Server setup

One transport at a time: UseWebSocket in settings chooses Node (WebSocket + REST) vs PHP (REST only).

Node.js (folder: .Server/websocket)

  • npm install
  • npm start (or npm run dev for auto-reload)
  • Unity REST: http://localhost:3001 · WS: ws://localhost:3001/ws?userId=<id>

PHP (folder: .Server/php)

  • Configure config.php
  • php -S localhost:3000 for local dev, or Apache/Nginx in production
  • Unity: http://localhost:3000 with Use WebSocket disabled
  • Send X-User-Id header on REST calls (see PHP README)

Node.js server — REST API

Base URL example: http://localhost:3001. Full list from package .Server/websocket/README.md:

Auth & friends

POST /api/auth
GET /api/friends
POST /api/friends/:friendId
DELETE /api/friends/:friendId

Friend requests

GET /api/friend-requests
POST /api/friend-requests
PUT /api/friend-requests/:requestId
DELETE /api/friend-requests/:requestId

Blocked users

GET /api/blocked-users
POST /api/blocked-users
DELETE /api/blocked-users/:userId

Rooms & invitations

GET /api/rooms/:userId
POST /api/rooms
PUT /api/rooms/:roomId
GET /api/invitations
POST /api/invitations
DELETE /api/invitations/:invitationId

Configuration (config.js)

KeyNotes
server.port / server.hostDefault listener (often 3001).
database.pathSQLite file (e.g. ./database/friends.db).
cors.allowedOriginsBrowser / client origins if applicable.
userTable.enabledOptional external user table integration.

WebSocket protocol (Node)

Connect to ws://localhost:3001/ws?userId=<user_id> (adjust host/port for production).

Client → server

{ "type": "heartbeat" }
{ "type": "status_update", "data": { "status": "online" } }
{ "type": "room_update", "data": { "playerCount": 5 } }

Server → client

{ "type": "connected", "data": { "userId": "..." } }
{ "type": "friend_request", "data": { "fromUserId": "...", "fromUsername": "..." } }
{ "type": "friend_status", "data": { "userId": "...", "status": "online" } }
{ "type": "invitation", "data": { "id": "...", "fromUserId": "...", "roomInfo": {...} } }
{ "type": "room_update", "data": { "roomId": "...", "playerCount": 5 } }
{ "type": "heartbeat_ack" }

PHP server — REST API

Include X-User-Id on requests. Endpoints from .Server/php/README.md:

POST /api/auth
GET /api/friends
POST /api/friends/:friendId
DELETE /api/friends/:friendId
GET /api/friend-requests
POST /api/friend-requests
PUT /api/friend-requests/:requestId
DELETE /api/friend-requests/:requestId
GET /api/blocked-users
POST /api/blocked-users
DELETE /api/blocked-users/:userId
GET /api/rooms
GET /api/rooms/:userId
POST /api/rooms
PUT /api/rooms/:roomId
GET /api/invitations
POST /api/invitations
DELETE /api/invitations/:invitationId

Configuration (config.php)

KeyNotes
database.typesqlite or mysql.
database paths / MySQL hostSee sample config.php in package.
cors.enabledToggle CORS for browser clients.

Server architecture

StackTransportStorageStrength
Node.jsWebSocket + HTTPSQLite (extensible)Push events, lower latency
PHPHTTP RESTSQLite / MySQLSimple shared hosting

Database schema

TablePurposeKey columns
usersProfiles & presenceid, username, status, last_seen
friendshipsRelationsuser_id, friend_id, status
friend_requestsRequest workflowsender_id, receiver_id, status
blocked_usersModerationuser_id, blocked_user_id
roomsSessionshost_id, player counts, metadata
invitationsInvitessender, receiver, room, state

See .Server/websocket/database/external_schema.sql for authoritative DDL if you extend the schema.

Network integration

BackendNative friendsElderWorldStudio customIdentity
Photon PUNYesYesPhoton user id
Photon FusionYesYesFusion player id
MirrorNoYesYour auth user id
Unity NetcodeVariesYesNGO client / auth id
FishNetVariesYesFishNet client id
CustomNoYesApplication-defined id

Troubleshooting

IssueLikely causeWhat to do
Initializer does nothingMissing settings assetAssign FriendManagerSettings; check execution order.
Backend type missingSDK not installedAdd Photon/Mirror/NGO/FishNet package or use Custom.
No realtime updatesWS down or wrong URLConfirm Node is running, firewall, and WebSocketUrl.
REST failuresWrong base URL / headerPHP: include X-User-Id; verify port and HTTPS.
Silent rejectionsBlocks / id mismatchCheck blocked list rules and user id mapping server-side.

Performance

AreaRecommendation
PresencePrefer WebSocket push for active sessions.
PollingUse RefreshInterval / PollingInterval in the 20–60s range when realtime is optional.
UIPool list items; diff lists instead of rebuilding every frame.
PayloadsTrim list DTO fields for mobile clients.
ServerScale WebSocket with sticky sessions and horizontal nodes.