Unity Setup Overview
This section covers everything you need to set up Universal Friend List in your Unity project. The system consists of three main components that work together to provide friend functionality.
Required Components
1. FriendManagerSettings (ScriptableObject)
A configuration asset that holds all the settings for your friend system. This is stored as a .asset file in your project and can be shared across scenes.
Purpose: Centralized configuration for backend type, server URLs, limits, and behavior flags.
Location: Assets/ElderWorldStudio/FriendList/Resources/FriendManagerSettings.asset (pre-created) or create your own via Assets → Create → ElderWorldStudio/Friend List → Friend Manager Settings
2. FriendManagerInitializer (Component)
A MonoBehaviour that wires up the friend system when your game starts. It connects the settings, creates the network system, and handles initialization.
Purpose: Bootstrap the friend system after user authentication, set the user ID, and control when initialization happens.
Placement: Add to a persistent GameObject in your first scene (like a GameManager).
3. FriendManager (Component)
The main runtime component that manages all friend operations. It handles events, coordinates with the network layer, and exposes UnityEvents for UI binding.
Purpose: Core business logic for friends, requests, blocking, and presence. Also provides game-type routing for invitations.
Placement: Automatically added by the initializer, or add manually to a DontDestroyOnLoad object.
Setup Options
Automatic Setup (Recommended)
Use the Editor Tools for the fastest setup:
- Open Window → ElderWorldStudio/Friend List
- Click Quick Setup
- The wizard will create all required objects and connect them
- Assign your settings asset if prompted
Manual Setup
For more control, set up components manually:
- Create an empty GameObject named "FriendSystem"
- Add the
FriendManagerInitializercomponent - Assign your
FriendManagerSettingsto the Initializer - Set
InitializeOnStart = true(or call Initialize() manually) - Add
FriendManagercomponent (created automatically by Initializer)
How Components Connect
Understanding the relationship between the three main components:
| Component | Creates | Depends On |
|---|---|---|
| FriendManagerInitializer | FriendManager, Network System | FriendManagerSettings, User ID |
| FriendManager | Events, Game Type Handler | Settings, Network System, User ID |
| FriendManagerSettings | None (data only) | None |
Initialization Flow
- Game starts →
FriendManagerInitializer.Awake() - Settings are validated and applied
- When Initialize() is called → Network system is created based on BackendType
- Network system connects → FriendManager initializes internal state
- FriendManager loads cached friends (if persistence enabled)
- FriendManager subscribes to network system events
- System is now ready for friend operations
UnityEvents for UI Binding
FriendManager exposes UnityEvents that you can wire up directly in the Inspector without code. This makes it easy to connect UI elements visually.
| Event | Trigger |
|---|---|
On Friend List Updated | Friend list refreshed or changed |
On Friend Request Received | New incoming friend request |
On Friend Request Accepted | Someone accepted your request |
On Friend Request Rejected | Someone rejected your request |
On Friend Request Cancelled | Request sender cancelled |
On Friend Status Changed | Friend came online/went offline |
On Friend Added | New friend successfully added |
On Friend Removed | Friend removed from list |
On User Blocked | User successfully blocked |
On User Unblocked | User removed from block list |
On Invitation Received | Game invitation received |
Next Steps
- FriendManagerSettings - Learn about all configuration options
- FriendManagerInitializer - Learn about initialization control
- FriendManager - Deep dive into the core component
- UI Components - Connect the user interface