Skip to content

styly-dev/STYLY-NetSync

Repository files navigation

STYLY NetSync for LBE

A Unity networking module and server for XR-powered Location Based Entertainment

version Unity 6 License DeepWiki

STYLY-NetSync_1200

STYLY-NetSync_1200

Overview

A minimal, high-performance networking package for Unity — built specifically for location-based entertainment (LBE) experiences. STYLY NetSync includes an easy-to-integrate Unity package and a lightweight Python server to make real-time, synchronized XR sessions easy to build and deploy in venue networks.

Highlights

  • Super easy to use — simple API and drop-in package so you can integrate fast and get running with minimal setup.
  • Super lightweight — low CPU / memory footprint; optimized network traffic for stable performance on local networks.
  • Optimized for LBE — syncs virtual and physical transforms and offers Human Presence (collision avoidance).

STYLY-NetSync_1200

STYLY-NetSync_1200

STYLY-NetSync_1200

Features

Main features

  • Avatar Transform Synchronization
  • RPC (Remote Procedure Call)
  • Network Variable

Other features

  • One-click SDK setup for HMDs
  • Multifunctional XR Rig
  • Battery level management

Some features are provided via dependent package STYLY XR Rig.

Installation

Prerequisites

uv/uvx: Required to start the server. OpenUPM: Required only when you add the package to your Unity project.

# Windows
winget install -e --id OpenJS.NodeJS.LTS --source winget
winget install -e --id astral-sh.uv --source winget
npm install -g openupm-cli

# Mac
brew install node
brew install uv
npm install -g openupm-cli

Add / Update STYLY-NetSync to Unity project

# Go to your unity project directory
cd YOUR_UNITY_PROJECT_DIR

# Add/Update NetSync package with specific version
openupm add -f com.styly.styly-netsync@0.7.5

Setup

Start NetSync server

# Start NetSync server
# Use the same version of the Unity package
uvx styly-netsync-server@0.7.5

# [Optional] Start client simulator
uvx --from styly-netsync-server@0.7.5 styly-netsync-simulator --clients 10

The uvx command automatically downloads the package, creates an isolated virtual environment, installs dependencies, and runs the python server program.

Setup Unity scene

SDK setup for HMDs STYLY XR Rig
Setup SDK
Downloads and installs SDK, and sets up configurations. See more details.
STYLY XR Rig
Supports most of samples in XR Interaction Toolkit, MR mode of HMDs, WASD control in Unity Editor mode and stick locomotion with HMD controllers.

NetSync Manager

Screenshot Description
Right click on the hierarchy window and select `STYLY NetSync` - `NetSyncManager` to add NetSyncManager.

Properties

  • _deviceId - Displays the unique device ID assigned to this client.
  • _clientNo - Shows the numeric client number assigned by the server.
  • _serverAddress - Server IP or hostname; leave empty to auto-discover on the local network.
  • _roomId - Identifier of the current room to join.
  • _localAvatarPrefab - Prefab used for the local user's avatar.
  • _remoteAvatarPrefab - Prefab used for remote users'avatars.
  • _humanPresencePrefab - Prefab shown at each remote user's physical position (used for "human presence" visualization).

Events

  • OnAvatarConnected - Triggered when a remote avatar connects to the network, passing the client number as an argument.
  • OnAvatarDisconnected - Triggered when a remote avatar disconnects from the network, passing the client number as an argument.
  • OnRPCReceived - Triggered when a Remote Procedure Call (RPC) is received from another client, passing the sender's client number, function name and arguments.
  • OnGlobalVariableChanged - Triggered when a global network variable is changed by another client, passing the variable name, old value and new value.
  • OnClientVariableChanged - Triggered when a client-specific network variable is changed by another client, passing the target client number, variable name, old value and new value.
  • OnReady - Triggered when the NetSyncManager is fully ready and connected to the server with handshake completed and network variables synchronized.

Unity C# API Reference

Namespace Import

// Import STYLY NetSync
using Styly.NetSync;

RPC

All RPC arguments are strings for simplicity.

// Broadcast to all clients in the room
NetSyncManager.Instance.Rpc("FunctionName", new string[] { "arg1", "arg2" });

// Receive RPCs
NetSyncManager.Instance.OnRPCReceived.AddListener((senderClientNo, functionName, args) =>
{
    Debug.Log($"RPC(senderClientNo): {senderClientNo}");
    Debug.Log($"RPC(functionName): {functionName}");
    foreach (var arg in args) Debug.Log($"RPC(args): {arg}");
});

Network Variable

All variable values are strings for simplicity.

// Set global variable (shared across all clients in room)
NetSyncManager.Instance.SetGlobalVariable("gameState", "playing");

// Set client-specific variable (set your own)
NetSyncManager.Instance.SetClientVariable("playerScore", "100");

// Set another client's variable (requires their client number)
NetSyncManager.Instance.SetClientVariable("health", "50", targetClientNo);

// Get variables
string gameState = NetSyncManager.Instance.GetGlobalVariable("gameState");
string score = NetSyncManager.Instance.GetClientVariable("playerScore", clientNo);

// Get variables with default value
string gameState = NetSyncManager.Instance.GetGlobalVariable("gameState", "Initial State");

// Listen for value changes
NetSyncManager.Instance.OnGlobalVariableChanged.AddListener((name, oldVal, newVal) => {
    Debug.Log($"Global var {name} changed: {oldVal} -> {newVal}");
});

NetSyncManager.Instance.OnClientVariableChanged.AddListener((clientNo, name, oldVal, newVal) => {
    Debug.Log($"Client {clientNo} var {name} changed: {oldVal} -> {newVal}");
});

For Maintainers

Testing with a Specific Branch

Unity: Install package with git URL.
https://github.com/styly-dev/STYLY-NetSync.git?path=STYLY-NetSync-Unity/Packages/com.styly.styly-netsync#develop

Server:
uvx --from "git+https://github.com/styly-dev/STYLY-NetSync@develop#subdirectory=STYLY-NetSync-Server" styly-netsync-server

Release Workflow

Use the Release Workflow GitHub Action.

Transport layer

STYLY NetSync uses ZeroMQ as its transport layer – C# (Unity): NetMQ – Python (server): pyzmq

License

This repository contains multiple sub-projects, each with its own license file. All sub-projects are licensed under the Apache License, Version 2.0.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 15