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.
Package contents
Everything ships under ElderWorldStudio/FriendList/. Sample servers live in .Server (hidden in Unity by default; still included for deployment).
Quick start
- Open
ElderWorldStudio/FriendList/Scenes/Demo.unity. - Select
Resources/FriendManagerSettings(or the assigned settings asset on the initializer). - Set Backend Type and Use Native Implementation to match your project.
- For the ElderWorldStudio custom server: set backend to Custom, configure Use WebSocket, Server URL, and WebSocket URL (see defaults in
FriendManagerSettings). - Enter Play Mode and verify list load, presence, requests, and invites.
.Server/websocket and point WebSocket to ws://localhost:3001/ws (see server section).Quick start video
Video tutorials
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
- Import the package into your project.
- Wait for script compilation to finish.
- Open the demo scene and confirm references (FriendManager, UI, settings).
Unity setup
1) FriendManagerSettings (ScriptableObject)
Create via Assets → Create → ElderWorldStudio → Friend List → Friend Manager Settings. Defaults use ElderWorldStudio-style URLs; override for your deployment.
| Field | Type | Default (code) | Purpose |
|---|---|---|---|
BackendType | NetworkBackendType | PhotonPUN | Selects integration path and identity source. |
UseNativeImplementation | bool | true | Use provider-native friends when available; turn off for ElderWorldStudio Node/PHP. |
PersistFriendList / PersistBlockList | bool | true | Persistence between sessions. |
RefreshInterval | float | 30 | List refresh when not using push paths. |
MaxFriends / MaxBlockedUsers | int | 100 | Client-side caps aligned with server rules. |
UseWebSocket | bool | true | true = Node (WS + REST); false = PHP REST only. |
ServerUrl | string | https://api.ElderWorldStudio.com/friends | REST base when polling or derived from WS host. |
WebSocketUrl | string | wss://api.ElderWorldStudio.com/friends/ws | WebSocket endpoint for realtime. |
PollingInterval | float | 5 | HTTP polling interval when WebSocket is off. |
2) FriendManagerInitializer
| Field | Notes |
|---|---|
Settings | Reference to FriendManagerSettings (required). |
InitializeOnStart | If false, call Initialize() manually after login. |
UserId | Optional 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).
| Path | Role |
|---|---|
Scripts/Managers/FriendManager.cs | Main friend manager, events, persistence keys, game-type routing. |
Scripts/Managers/FriendManagerSettings.cs | ScriptableObject settings. |
Scripts/Managers/FriendManagerInitializer.cs | Wires backend implementation and user id. |
Scripts/Abstractions/INetworkFriendSystem.cs | Network friend API contract. |
Scripts/Abstractions/IFriendManager.cs | Friend manager interface. |
Scripts/Abstractions/IGameTypeHandler.cs | Game-type handler contract. |
Scripts/Abstractions/BaseGameTypeHandler.cs | Base for game-type handlers. |
Scripts/Abstractions/NetworkBackendType.cs | PhotonPUN, PhotonFusion, Mirror, UnityNetcode, FishNet, Custom. |
Scripts/Abstractions/IServerClient.cs | Server client abstraction. |
Scripts/Networking/BaseNetworkFriendSystem.cs | Shared network friend logic. |
Scripts/Networking/BaseCustomFriendSystem.cs | Custom / HTTP-WS client stack. |
Scripts/Networking/CustomBackendFriendSystem.cs | Custom backend wiring. |
Scripts/Networking/Photon/PhotonPunNativeFriendSystem.cs | PUN native. |
Scripts/Networking/Photon/PhotonPunCustomFriendSystem.cs | PUN + ElderWorldStudio server. |
Scripts/Networking/Photon/PhotonFusionNativeFriendSystem.cs | Fusion native. |
Scripts/Networking/Photon/PhotonFusionCustomFriendSystem.cs | Fusion + ElderWorldStudio server. |
Scripts/Networking/Mirror/MirrorCustomFriendSystem.cs | Mirror + ElderWorldStudio server. |
Scripts/Networking/Unity/UnityNetcodeNativeFriendSystem.cs | NGO native path. |
Scripts/Networking/Unity/UnityNetcodeCustomFriendSystem.cs | NGO + ElderWorldStudio server. |
Scripts/Networking/FishNet/FishNetNativeFriendSystem.cs | FishNet native path. |
Scripts/Networking/FishNet/FishNetCustomFriendSystem.cs | FishNet + ElderWorldStudio server. |
Scripts/Networking/Server/ElderWorldStudioServerClient.cs | HTTP client to ElderWorldStudio-compatible API. |
Scripts/Networking/Server/ElderWorldStudioWebSocketClient.cs | WebSocket client. |
Scripts/Networking/Server/ElderWorldStudioServerConfig.cs | Server config asset / runtime config. |
Scripts/Networking/Server/ElderWorldStudioAuthHandler.cs | Auth helper. |
Scripts/Networking/Server/ElderWorldStudioLogger.cs | Logging helper. |
Scripts/Networking/Server/ElderWorldStudioErrorHandler.cs | Error handling helper. |
Scripts/Networking/Server/ServerDTOs.cs | DTOs for server payloads. |
Scripts/GameTypes/GameTypeManager.cs | Registers and selects game-type handlers. |
Scripts/GameTypes/GameTypeFactory.cs | Factory for game types. |
Scripts/GameTypes/GameTypeSettings.cs | Shared settings base. |
Scripts/GameTypes/RoomBasedGameTypeHandler.cs | Room-based invitations / joins. |
Scripts/GameTypes/OpenWorldGameTypeHandler.cs | Open-world style behavior. |
Scripts/GameTypes/Examples/RoomBasedGameTypeSettings.cs | Example room settings. |
Scripts/GameTypes/Examples/OpenWorldGameTypeSettings.cs | Example open-world settings. |
Scripts/Models/Friend.cs | Friend model. |
Scripts/Models/FriendRequest.cs | Friend request model. |
Scripts/Models/FriendRequestStatus.cs | Request status enum. |
Scripts/Models/FriendStatus.cs | Presence / status enum. |
Scripts/Models/FriendInvitation.cs | Invitation model. |
Scripts/Models/InvitationStatus.cs | Invitation status enum. |
Scripts/Models/RoomInfo.cs | Room metadata. |
Scripts/Models/BlockEntry.cs | Block list entry. |
Scripts/UI/FriendListUI.cs | Main friend list UI controller. |
Scripts/UI/FriendListItemUI.cs | Friend row. |
Scripts/UI/FriendRequestItemUI.cs | Request row. |
Scripts/UI/FriendRequestsUI.cs | Requests panel logic. |
Scripts/UI/AddFriendUI.cs | Add-friend UI. |
Scripts/Examples/SimpleCustomConnection.cs | Example custom connection. |
Scripts/Examples/NetworkConnections/SimplePun2Connection.cs | PUN example. |
Scripts/Examples/NetworkConnections/SimplePhotonFusionConnection.cs | Fusion example. |
Scripts/Examples/NetworkConnections/SimpleMirrorConnection.cs | Mirror example. |
Scripts/Examples/NetworkConnections/SimpleUnityNetcodeConnection.cs | NGO example. |
Scripts/Examples/NetworkConnections/SimpleFishNetConnection.cs | FishNet example. |
Scripts/Editor/FriendManagerSettingsInspector.cs | Custom inspector for settings. |
Scripts/Editor/FriendManagerInitializerInspector.cs | Initializer inspector. |
Scripts/Editor/FriendListEditorWindow.cs | Editor window. |
Scripts/Editor/FriendListQuickSetup.cs | Quick setup utilities. |
Scripts/Editor/FriendListSetupWizard.cs | Setup wizard. |
Scripts/Editor/FriendListUIGenerator.cs | UI generation. |
Scripts/Editor/FriendListItemGenerator.cs | Item generation. |
Scripts/Editor/NetworkBackendValidator.cs | Backend validation. |
Prefabs & content
| Asset | Notes |
|---|---|
Prefabs/FriendListUI.prefab | Main social panel shell. |
Prefabs/FriendListItem.prefab | Friend row (alternate naming: see also Friend List Item.prefab). |
Prefabs/Friend List Item.prefab | Spaced-name duplicate style prefab in package. |
Prefabs/FriendRequestItem.prefab | Incoming/outgoing request row. |
Prefabs/Friend Request Item.prefab | Spaced-name variant. |
Prefabs/InvitationItem.prefab | Invitation row. |
Prefabs/BlockedUserItem.prefab | Blocked user row. |
Content/UI/ | Icons and UI images used by samples. |
Resources/FriendManagerSettings.asset | Sample settings (adjust or duplicate per environment). |
Resources/ServerConfig.asset | Server 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
| Mode | Data source | Realtime | Best for |
|---|---|---|---|
| Native | Provider friend APIs | Provider-dependent | Fastest integration inside one ecosystem. |
| Photon PUN / Fusion native | Photon services | Strong | Photon-first titles. |
| Custom (ElderWorldStudio server) | Node or PHP + your auth | High with WebSocket | Cross-stack consistency, moderation, custom rules. |
| Mirror / NGO / FishNet + custom | ElderWorldStudio-compatible API | High with WebSocket | Dedicated servers and bespoke gameplay. |
Unity components
FriendManager
Scripts/Managers/FriendManager.cs — implements IFriendManager; exposes UnityEvents for inspector wiring.
Serialized configuration
| Field | Description |
|---|---|
_backendType | NetworkBackendType selector. |
_useNativeImplementation | Native vs ElderWorldStudio custom server. |
_persistFriendList / _persistBlockList | Local persistence. |
_refreshInterval | Polling interval for non-push paths. |
_maxFriends / _maxBlockedUsers | Limits. |
_defaultGameType | Room-based vs open-world style routing. |
_autoInitializeGameType | Auto-bind game-type handler. |
UnityEvents (inspector)
| UnityEvent | Payload | When |
|---|---|---|
_onFriendListUpdated | List<Friend> | Friend list refreshed. |
_onFriendRequestReceived | FriendRequest | New incoming request. |
_onFriendRequestAccepted | FriendRequest | Request accepted. |
_onFriendRequestRejected | FriendRequest | Request rejected. |
_onFriendRequestCancelled | FriendRequest | Request cancelled. |
_onFriendStatusChanged | Friend, FriendStatus | Presence changed. |
_onFriendAdded / _onFriendRemoved | Friend | Friend added or removed. |
_onUserBlocked | BlockEntry | User blocked. |
_onUserUnblocked | string (user id) | User unblocked. |
_onInvitationReceived | FriendInvitation | Invitation received. |
FriendManagerSettings
Scripts/Managers/FriendManagerSettings.cs — same fields as listed in Unity setup; shared across scenes via reference.
FriendManagerInitializer
Scripts/Managers/FriendManagerInitializer.cs — Initialize(), 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.
INetworkFriendSystem API
Implemented per backend (native or custom). Common operations:
| Member | Summary |
|---|---|
Properties: BackendType, IsUsingNativeImplementation, IsConnected | State. |
| Events: list updated, request received, requests updated, status changed, invitation received | Mirror server events into C#. |
Initialize(string userId) | Start session for current user. |
RefreshFriendList() / RefreshFriendRequests() | Pull latest data. |
SendFriendRequest, AcceptFriendRequest, RejectFriendRequest, CancelFriendRequest | Request lifecycle. |
RemoveFriend | Unfriend. |
BlockUser / UnblockUser | Blocking. |
GetFriendRoomInfo, JoinFriendRoom, InviteFriend | Rooms and invites (RoomInfo). |
Server setup
UseWebSocket in settings chooses Node (WebSocket + REST) vs PHP (REST only).Node.js (folder: .Server/websocket)
npm installnpm start(ornpm run devfor auto-reload)- Unity REST:
http://localhost:3001· WS:ws://localhost:3001/ws?userId=<id>
PHP (folder: .Server/php)
- Configure
config.php php -S localhost:3000for local dev, or Apache/Nginx in production- Unity:
http://localhost:3000withUse WebSocketdisabled - Send
X-User-Idheader 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
/api/auth/api/friends/api/friends/:friendId/api/friends/:friendIdFriend requests
/api/friend-requests/api/friend-requests/api/friend-requests/:requestId/api/friend-requests/:requestIdBlocked users
/api/blocked-users/api/blocked-users/api/blocked-users/:userIdRooms & invitations
/api/rooms/:userId/api/rooms/api/rooms/:roomId/api/invitations/api/invitations/api/invitations/:invitationIdConfiguration (config.js)
| Key | Notes |
|---|---|
server.port / server.host | Default listener (often 3001). |
database.path | SQLite file (e.g. ./database/friends.db). |
cors.allowedOrigins | Browser / client origins if applicable. |
userTable.enabled | Optional 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:
/api/auth/api/friends/api/friends/:friendId/api/friends/:friendId/api/friend-requests/api/friend-requests/api/friend-requests/:requestId/api/friend-requests/:requestId/api/blocked-users/api/blocked-users/api/blocked-users/:userId/api/rooms/api/rooms/:userId/api/rooms/api/rooms/:roomId/api/invitations/api/invitations/api/invitations/:invitationIdConfiguration (config.php)
| Key | Notes |
|---|---|
database.type | sqlite or mysql. |
database paths / MySQL host | See sample config.php in package. |
cors.enabled | Toggle CORS for browser clients. |
Server architecture
| Stack | Transport | Storage | Strength |
|---|---|---|---|
| Node.js | WebSocket + HTTP | SQLite (extensible) | Push events, lower latency |
| PHP | HTTP REST | SQLite / MySQL | Simple shared hosting |
Database schema
| Table | Purpose | Key columns |
|---|---|---|
users | Profiles & presence | id, username, status, last_seen |
friendships | Relations | user_id, friend_id, status |
friend_requests | Request workflow | sender_id, receiver_id, status |
blocked_users | Moderation | user_id, blocked_user_id |
rooms | Sessions | host_id, player counts, metadata |
invitations | Invites | sender, receiver, room, state |
See .Server/websocket/database/external_schema.sql for authoritative DDL if you extend the schema.
Network integration
| Backend | Native friends | ElderWorldStudio custom | Identity |
|---|---|---|---|
| Photon PUN | Yes | Yes | Photon user id |
| Photon Fusion | Yes | Yes | Fusion player id |
| Mirror | No | Yes | Your auth user id |
| Unity Netcode | Varies | Yes | NGO client / auth id |
| FishNet | Varies | Yes | FishNet client id |
| Custom | No | Yes | Application-defined id |
Troubleshooting
| Issue | Likely cause | What to do |
|---|---|---|
| Initializer does nothing | Missing settings asset | Assign FriendManagerSettings; check execution order. |
| Backend type missing | SDK not installed | Add Photon/Mirror/NGO/FishNet package or use Custom. |
| No realtime updates | WS down or wrong URL | Confirm Node is running, firewall, and WebSocketUrl. |
| REST failures | Wrong base URL / header | PHP: include X-User-Id; verify port and HTTPS. |
| Silent rejections | Blocks / id mismatch | Check blocked list rules and user id mapping server-side. |
Performance
| Area | Recommendation |
|---|---|
| Presence | Prefer WebSocket push for active sessions. |
| Polling | Use RefreshInterval / PollingInterval in the 20–60s range when realtime is optional. |
| UI | Pool list items; diff lists instead of rebuilding every frame. |
| Payloads | Trim list DTO fields for mobile clients. |
| Server | Scale WebSocket with sticky sessions and horizontal nodes. |
Links & support
- Unity Asset Store: use the top bar button — set
hrefon#link-asset-storein this file to your listing URL when published. - Official site: set
hrefon#link-official-siteto your documentation or company page. - Included readmes:
.Server/websocket/README.mdand.Server/php/README.mdfor server-only details.