Skip to content

Unity Examples

In this section of the documentation we provide a series of tutorials on the C# examples for the Unity platform distributed as a dedicated package on the SmartFoxServer 3 download page. The examples have been developed in Unity 6, but the concepts and the code to interact with the SFS3 API are valid for any version of Unity.

Each tutorial examines a single example, describing its objectives, offering an insight into the SmartFoxServer features it wants to highlight and providing the direct link to download the source code. This includes all the assets required to compile and test the example (both client and — if existing — server side). If necessary, code excerpts are provided in the tutorial itself, in order to better explain the approach that was followed to implement a specific feature. At the bottom of the tutorial, additional resources are linked if available.

The tutorials have an increasing complexity, from basic server connection to full realtime games with authoritative server Extension.

Specifically, the examples show:

  1. Basic connection with optional protocol encryption
  2. Room management
  3. Buddy list management
  4. Game Rooms and match-making
  5. Authoritative server in a turn-based game
  6. MMO-related features
  7. Clients synchronization in realtime games
  8. Audio streaming for in-game voice chat

Build targets

All examples run seamlessly and are interoperable on all Unity build targets. For sake of simplicity, the examples have been developed for desktop usage, so they may have UI issues running on devices.

Please note that due to the different requirements of the Unity build targets, the SmartFoxServer C# API distributed with the examples includes two separate DLLs: a DLL specific for WebGL builds and a DLL for all other Unity target platforms (including the Unity Editor itself).

Most examples use both DLLs, with the WebGL one located in its dedicated subfolder under the Plugins/ folder. For more information check the API setup instructions.

Requirements

Unless otherwise noted inside the tutorials:

  • all examples are distributed as a single package and the same download link is provided in all the tutorials;
  • all examples have been developed in Unity 6.3 LTS and distributed as Unity projects: add a project to the Unity Hub and launch it (the first time it will take a few seconds to Unity to regenerate the required libraries for the project);
  • the server side Extensions of those examples which feature one have been developed in Eclipse, but you should be able to use any Java IDE of your choice, provided you use Java 21 or higher.
  • all the examples make use of the latest version of the SmartFoxServer 3 C# API available at the time of their release; as the API evolves over time (bug fixes, new features), we strongly recommend that, after installing an example, you overwrite the included API DLL files with those provided in the latest SmartFoxServer C# API package available on our website.