Skip to content

unigine-engine/unigine-photon-csharp-integration-sample

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Photon Integration Sample

Photon is a networking engine and multiplayer platform that handles all communication on its own servers. In a typical multiplayer setup, you implement the core application (gameplay) logic within your UNIGINE project, while Photon manages the networking layer.

This sample includes two Photon products:

  • Photon Realtime - real-time communication between multiple players over the network. Suitable for multiplayer shooters, racing games, and other latency-sensitive applications.
  • Photon Chat – public/private in-game chat system.

The sample includes the following functional elements:

  • Authorization Window – Simple login interface where users enter a nickname; extendable to include more advanced authentication (e.g., passwords).
  • Lobby Window – A UI to create rooms and browse the list of available rooms to join.
  • Gameplay World – The main interactive scene where objects can be manipulated in real time + chat panel.

This gives a solid foundation for for building your own UNIGINE-based multiplayer applications using Photon's networking services. From there, you can explore and integrate additional Photon products as needed.

Data Transfer via Photon

Photon doesn’t natively support UNIGINE types. To send such data over the network, it must be serialized before transmission and deserialized upon receipt. This sample provides utility code for that, including:

  1. Common data types supported by Photon - listed here under Common-cpp.
  2. More complex data types (e.g. transformation matrices) requiring explicit registration for custom serialization.

How to Run the Sample

Prerequisites

Step-by-Step Guide

  1. Clone or download the sample.

  2. Open SDK Browser and make sure you have the latest version.

  3. Add the sample project to SDK Browser:

    • Go to the My Projects tab.

    • Click Add Existing, select the .project file from the cloned folder (matching your OS - *-win-*/*-lin-*, edition, precision), and click Import Project.

      Add Project

  4. Repair the project:

    • After importing, you'll see a Repair warning - this is expected, as only essential files are stored in the Git repository. SDK Browser will restore the rest.

    Repair Project

    • Click Repair and then Configure Project.
  5. Download Photon Realtime C# .NET SDK (v4.1.8.17) from photonengine.com. If you don’t have an account, you’ll need to register first.

Photon SDKs

  1. Copy Photon SDK files:
    • From downloaded SDK’s /source, copy the following folders into your project’s source/PhotonSDK:
      • libs
      • PhotonChatApi
      • PhotonLoadbalancingApi

Tip

You can quickly access your project via SDK Browser by clicking the three dots next to your project's name and selecting Open Folder.

Project Folder

  1. Build Photon libraries:

    • Open DotNetCloudSdk.sln in VS 2022.
    • Build solution.
    • Copy Photon‑NetStandard.dll, Photon-NetStandard.pdb, and Photon-NetStandard.xml from libs/Release/netstandard2.0 to your project’s bin.
  2. Create App IDs in Photon Dashboard:

    • Go to the Dashboard at photonengine.com (the tab in the top right corner) and click CREATE A NEW APP.

    Photon App

    • Create two apps: Realtime Photon SDK and Chat Photon SDK.
    Realtime App Chat App
    Creating a Realtime Photon App Creating a Chat Photon App
    • Copy the generated App IDs in your sample project. The same ID is used for every instance (i.e. other participants don't need to create their own apps).

    Photon ID

  3. Add App IDs to the sample project: open data/application_params.json in your project /data folder and paste IDs:

    {
      "realtime_application_id": "YOUR_REALTIME_ID",
      "realtime_application_version": "1.0",
      "chat_application_id": "YOUR_CHAT_ID",
      "chat_application_version": "1.0"
    }
  4. Open the project in UnigineEditor via the SDK Browser, and click Run to launch the application.

Run App

If the sample fails to run:

  • Ensure source/PhotonSDK and bin have all required files.
  • Verify your SDK version is not older than the project's specified version.
  • Make sure the correct .project file is used for your platform and SDK edition.
  • If missing assembly errors occur, verify SDK folder/library placement.
  • For build issues: right-click project → Rebuild.

How to Use the Sample

  1. Run the sample and enter a nickname in the authorization form → click Join Lobby.

Photon Authorization

  1. If no rooms exist, create one (Create Room).

Photon Create Lobby

  1. Other users with the same App IDs in data/application_params.json will see and can join it.

Photon Lobby

  1. Double‑click the room name to enter.

  2. In the world, control the material ball with:

    • WASD to move
    • QE to rotate
    • Left click to shoot.
  3. Use the chat panel:

    • Send global messages
    • Send private messages by typing @username.

Photon Messages

  1. As the health bar is empty, click Leave to return to Lobby.

About

Unigine Csharp Photon Integration Sample

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages