User Search System
Comprehensive documentation for the BlinkBox User Search Addon
Introduction
The User Search addon provides a powerful interface for players to find other users by name, view their basic profiles, and send friend requests. It includes a random user discovery feature to encourage social interaction.
Core Capabilities
- Search by Name: Real-time querying of the database to find users.
- Random Discovery: Automatically suggests random users when the search window opens.
- Friend Integration: Seamlessly integrates with the Friend List and Friend Request addons.
- Profile Preview: Displays avatars, calling cards, levels, and scores.
Setup & Installation
1. Database Setup
- Upload
bl_UserSearch.phpto your web server (same directory as MFPS PHP files). - Upload
bl_UserUID.phpto the same directory (required for UID management).
2. Unity Setup
- Add the User Search UI prefab to your Lobby canvas.
- Ensure a
bl_UserUIDManageris present in the scene (or use the provided manager prefab). - Configure the settings in Resources/UserSearchSettings.
Architecture
bl_UserSearch
The main controller script attached to the UI panel.
- Handles input field events and "Search" button clicks.
- Communicates with the PHP backend to fetch user data.
- Instantiates
bl_UserSearchUIprefabs for each result.
bl_UserSearchUI
Represents a single user entry in the results list.
- Data Display: Shows Nickname, Level, Avatar, Calling Card.
- Friend Logic: Checks
bl_FriendListBaseto see if the user is already a friend. - Interaction: Handles the "Add Friend" button click, sending requests via
bl_FriendRequest(if available).
Key Features
Random User Loading
To keep the community active, the system can load a list of random users when the search panel is opened. This is controlled by the LoadRandomUsersOnStart setting.
// Manually trigger random user refresh
public void RefreshRandomUsers()
{
if (settings.loadRandomUsersOnStart)
{
StartCoroutine(LoadRandomUsersOnStart());
}
}
Smart Friend Status
The UI automatically detects the relationship status with the searched user:
- Self: Hides the entry or disables interaction.
- Friend: Shows a "Friend" icon/label; disables "Add" button.
- Stranger: Shows "Add Friend" button.
- Request Sent: (With FriendRequest addon) Shows "Request Sent" status.
UID System
The addon includes a robust UID (Unique Identifier) management system via bl_UserUIDManager.
bl_UserUIDManager
A singleton that manages the synchronization of UIDs. It can run in "Cron Mode" to batch update user records in the database.
Usage
// Run a manual UID update check
bl_UserUIDManager.Instance.UpdateUIDs();
// Run in Cron Mode (faster timeout, used for automated tasks)
bl_UserUIDManager.Instance.TestCronJob();
Configuration
Settings are managed via the UserSearchSettings ScriptableObject.
| Setting | Description |
|---|---|
| PHP Files | Names of the PHP scripts (default: bl_UserSearch.php, bl_UserUID.php). |
| Max Search Results | Limit on how many users are returned per query. |
| Random Users Count | How many random users to show on start (default: 10). |
| Shuffle Users | Randomize the order of results locally. |
| Cache Data | Cache results for X seconds to reduce server load. |