by Pivec Labs
Manual Full reference

NetCrafter Pro — Manual

Full reference for every tab, field, and control in the NetCrafter editor window. Open it from Tools → Pivec Labs → NetCrafter Pro.

Definition · Code · Settings · Scenes Reference

Definition Section#

Schema Bar

The schema bar runs across the top of every section. It shows a dropdown of all discovered definitions (schemas found anywhere under Assets/PivecLabs/NetCrafter/Definitions/). Selecting a definition switches the entire window to that definition's assets.

Click Create Definition when no definition exists or to add a new one.

Messages Tab

Displays all GameplayMessageDefinition assets found in Definitions/{Name}/Messages/.

To create a message: click Create Gameplay Message.

Message Fields

FieldDescription
Message NameThe base class name. A ClientToServer message generates {Name}Request.cs. A ServerToClient message generates {Name}Event.cs.
DirectionClientToServer — client sends to server (becomes a Request). ServerToClient — server pushes to client (becomes an Event). ClientToServerToAll — client sends; server re-broadcasts to all (also becomes a Request).
TransportAlways ExtensionRequest for the current generator. Other transport types are reserved for future use.
Server Handler NameThe name that must match a Server Action's Handler Name. Validation will fail if no matching Server Action exists.
FieldsThe data payload. Each field has a Name and a Type.

Field Types

Schema typeC# typeSFS3 wire formatNotes
intintPutInt / GetInt
floatfloatPutFloat / GetFloat
boolboolPutBool / GetBool
stringstringPutString / GetString
Vector2Vector2PutFloatArray (2 floats)
Vector3Vector3PutFloatArray (3 floats)
QuaternionQuaternionPutFloatArray (4 floats)Edit asset YAML directly to use
PlayerIdintPutInt / GetIntSemantic alias for player IDs
ItemIdstringPutString / GetStringSemantic alias for item identifiers
ModelNameModelNamePutSFSObject / nested ISFSObjectEdit asset YAML: set type: ModelName

Arrays: any field type can be made an array. Edit the asset YAML directly and set isArray: 1. The generated C# field becomes List<T> and uses SFSArray on the wire.

The editor type dropdown exposes int, float, string, bool, Vector2, Vector3, PlayerId, and ItemId. To use Quaternion, nested model types, or array fields, open the .asset file in a text editor and edit the YAML directly.

Data Definitions Tab

Displays all DataDefinition assets in Definitions/{Name}/DataDefinitions/.

A Data Definition defines a reusable data model. The generator produces a {Name}.cs class with serialisation helpers (ToSFSObject() and FromSFSObject()).

To create a model: click Create Data Definition. Set a Model Name and add fields exactly as you would for a message.

Server Actions Tab

Displays all ServerActionDefinition assets in Definitions/{Name}/ServerActions/.

Server Actions serve two purposes: satisfying the validation check (every message's Server Handler Name must match at least one Server Action's Handler Name) and driving server-side Java code generation.

FieldDescription
Handler NameMust match the Server Handler Name on one or more messages or events.
Trigger MessageOptional reference to the message that triggers this action.
Logic TypeBroadcastAll, BroadcastAOI, SenderOnly, TargetUser, or Custom. Used for server code generation.
Custom Java CodeFreeform Java code for the Custom logic type. Used for server code generation.

Sync Rules Tab

Displays all SyncRuleDefinition assets in Definitions/{Name}/SyncRules/.

Click Create Sync Rule to add a new rule. Select a rule in the left panel to edit its details on the right.

FieldDescription
Rule NameIdentifier for this rule. Also used as the network command suffix: __nc_sync_{RuleName}.
Sync TargetThe component property to synchronise. See the table below.
Sync ModeAlways, OnChange, or Interval. See below.
IntervalSeconds between syncs when Sync Mode is Interval. Default: 0.05 (20 Hz).

Sync Targets

TargetComponentProperty
Transform_PositionTransformposition (world space)
Transform_RotationTransformrotation (world space quaternion)
Transform_ScaleTransformlocalScale
Rigidbody_VelocityRigidbodylinearVelocity
Rigidbody_AngularVelocityRigidbodyangularVelocity

Sync Modes

ModeBehaviour
AlwaysSends every FixedUpdate. Use for values that change every frame (e.g. position of a moving character).
OnChangeSends only when the value has changed by more than an epsilon since the last send (0.001 units for Vector3, 0.1 degrees for rotation). Lower bandwidth cost; adds a single-frame detection lag.
IntervalSends every N seconds (interval field). Use for infrequently-changing values or where exact timing matters more than immediate response.

Sync rules are stored in the schema and exported for validation. The runtime system is implemented via NetCrafterSyncManager and NetCrafterSyncBinding — see the Sync Rule Runtime section.

Code Section#

Build Code Tab

ControlAction
Validate DefinitionRuns the validator and shows a success dialog or opens the error window. Does not generate any files.
Preview JSONOpens a read-only window showing the raw schema JSON that will be passed to the generator.
Generate All FilesValidates, then generates client code, server code, and config.
Client OnlyValidates, then generates client C# files only.
Server OnlyValidates, then runs the server generator (currently a stub — no files produced).
Open Output FolderReveals the schema's Generated/ folder in Explorer.

All generation paths run schema validation first. If validation fails the error window opens and generation is aborted.

Generated client files land in Definitions/{Name}/Generated/Client/.

Schema Validation

The validator (NC_ValidateSchema) performs four checks in order:

  1. Duplicate names — no two messages, events, or models may share a name; no message and model may share a name.
  2. Invalid field types — all field types must be a supported primitive or a declared model name.
  3. Missing handler references — every message and event must name a handler that exists in the Server Actions list.
  4. Circular model references — model fields must not form a cycle (e.g. A references B which references A).

Errors are shown in a scrollable Validation Error Window. Fix all errors before generating.

Code Preview Tab

Displays the generated files for the selected definition, split into three groups: Client, Server, Config.

Group tabShows
Client (n)All .cs files in Generated/Client/
Server (n)All .cs files in Generated/Server/
Config (n)All files in Generated/Config/

Selecting a file displays it in the right panel with syntax highlighting.

Normal / Diff toggle: after you generate at least once, the toggle becomes active. Diff view compares the on-disk file against a snapshot captured immediately before the last generation run. Added lines have a green background; removed lines have a red background.

ButtonAction
CopyCopies the file content to the clipboard
Open ↗Opens the file in the system default application
Normal / DiffToggles between syntax-highlighted view and diff view

Server Code Tab

Generates a complete Java SFS3 extension project from your schema and provides one-click build and deploy.

Prerequisites

  • Maven installed and on PATH
  • JDK 21 required (not 17): SFS3 JARs are compiled with Java 21. JDK 17 will fail with "bad class file" errors even if the classpath appears correct. Recommended: Eclipse Adoptium JDK 21 — winget install EclipseAdoptium.Temurin.21.JDK
  • SmartFoxServer 3 installed locally or accessible

NetCrafter auto-detects Maven and JDK 21 from standard install locations (M2_HOME, MAVEN_HOME, PATH, C:\Program Files\Eclipse Adoptium, C:\Program Files\Java). No manual path configuration is required.

Workflow

  1. Set Extension Class and Extension Name in Settings → SmartFox Settings. Extension Class must be fully qualified (e.g. com.company.game.MyExtension).
  2. Set SFS3 Lib Path and SFS3 Extensions Path in Settings → Project Settings (Server Build Settings section).
  3. Click Generate Server Code — creates the Java project in Definitions/{Name}/Generated/Server/.
  4. Click Build JAR (mvn package) — compiles the project and produces target/{ExtensionName}.jar.
  5. Click Deploy to SFS3 — runs Maven and copies the JAR to your SFS3 extensions folder directly (no script file involved).
  6. Start (or restart) your SFS3 server and check the server log for {ExtensionName}: {ExtensionClass} initialized.

Generated Files

FileDescription
{ExtensionClass}.javaSFS3 extension entry point; registers all handlers in init()
handlers/Handle{Message}.javaOne handler per Server Action; reads params, builds response, sends
models/{Model}.javaOne model per Data Definition; toSFSObject() / fromSFSObject() helpers
pom.xmlMaven build file; declares SFS3 JARs as system-scope dependencies

Zone Configuration

To activate the extension in SFS3, update your zone XML (e.g. zones/Playground.zone.xml):

XML · zone configuration
<extension>
  <name>MyGame</name>
  <type>JAVA</type>
  <file>com.mygame.MyGameExtension</file>
  <reloadMode>AUTO</reloadMode>
</extension>

Coming Soon — Server Code

Coming SoonBroadcastAOI full implementation

TODO comment generated; full MMO proximity API not yet wired.

Coming SoonServer event handlers (ServerToClient push)

Server-initiated push events not yet generated.

Config Generator Tab

Generates a complete zone config XML ({zoneName}.zone.xml) for SmartFoxServer 3 from the current schema's SmartFox Settings asset.

ButtonAction
Refresh PreviewRe-derives the XML from the current SmartFox Settings without writing to disk. The preview can go stale if you edit Settings after opening the tab — click this to update it.
Generate {zoneName}.zone.xmlWrites the zone config XML to Definitions/{Name}/Generated/Config/{zoneName}.zone.xml and calls AssetDatabase.Refresh(). Also reveals the file in Explorer.
Open Config FolderReveals Generated/Config/ in Explorer without writing.

The generated file includes TCP and WebSocket socket config, a Zone block, an MMORoom or plain Room element, and an Extension element (only when Extension Name and Extension Class are set).

Settings Section#

SmartFox Settings Tab

Settings are stored in Definitions/{Name}/SmartFoxSettings.asset — one asset per definition.

Connection

FieldDefaultDescription
HostlocalhostServer hostname or IP address
TCP Port9977TCP port (SFS3 default is 9977, not 9933)
WebSocket Port9977WebSocket port (used if WebSocket transport is active)
Zone NameBasicZoneZone as defined in your server zones.xml
Auto-ReconnecttrueReserved for future use
Debug LoggingtrueEnables SFS3 client-side verbose logging

Login

FieldDefaultDescription
Login ModeGuestGuest: sends an empty username. UsernamePassword and Custom are reserved for future use.
Guest Name PrefixPlayer_Prefix prepended to the auto-assigned guest name

Extension

FieldDefaultDescription
Extension NameBasicExtensionName of the SFS3 extension handling requests
Extension Classcom.piveclabs.BasicExtensionFully qualified Java class name
Send Queue Size4096Bytes
Max Message Size32768Bytes

MMO

FieldDefaultDescription
Enable MMO ModetrueEnables the SFS3 MMO API (proximity-based interest management)
Map BoundsX: −50 to 50, Z: −50 to 50World-space boundary of the MMO map
View AreaWidth: 20, Height: 20Proximity range for area-of-interest queries
Interest ModeGridGrid, Radius, or Custom

Click Save Settings to persist changes. Click Reset to Defaults to restore the values shown above.

Project Settings Tab

Settings are stored in Definitions/{Name}/ProjectSettings.asset.

Output Folders

Read-only display of the three output paths, all derived from the schema's definition folder. Cannot be changed manually.

Template Settings

FieldDescription
Use Custom TemplatesWhen enabled, the generator looks for override templates in Definitions/{Name}/Templates/ before falling back to the built-in templates.

When Use Custom Templates is on, the Override Folder path is shown and the Template Files grid appears. See the Template Guide for full details.

Naming Conventions

FieldDefaultDescription
NamespacePivecLabs.GeneratedC# namespace used in all generated files
Class PrefixemptyPrepended to every generated class name
Class SuffixemptyAppended to every generated class name

Generation Behaviour

FieldDefaultDescription
Overwrite Existing FilestrueWhen false, the generator skips files that already exist on disk
Show Summary After BuildtrueReserved — generation summary logging is always written to the Unity console

Logging

FieldDefaultDescription
Verbose LoggingfalsePasses the flag to the generator; currently only affects console log output

Experimental Features

FieldDescription
Enable Partial Class SupportReserved — not yet wired to the generator
Enable Advanced Sync RulesReserved — not yet wired to the generator

Scenes Section#

Prefab Generator Tab

The Prefab Generator creates Unity prefabs for use in your multiplayer scene.

ConnectionManager Prefab

The Create ConnectionManager Prefab button packages the generated SmartFoxConnectionManager.cs into a reusable prefab saved to Definitions/{Name}/Generated/Prefabs/ConnectionManager.prefab.

Requirements: client code must have been generated first (Build Code tab). The panel shows the expected output path and whether the prefab already exists.

Coming Soon — Prefab Generator

The following sections are visible in the UI but greyed out.

Coming SoonPlayer Prefab

Generate a player prefab from a base prefab, optionally adding NetworkIdentity, MovementSync, RotationSync, AnimationSync, and HealthSync components.

Coming SoonChat UI

Generate a UI prefab in Minimal, Modern, or MMO-Style layouts.

Coming SoonNPC Prefab

Generate an NPC prefab with configurable AI and synchronisation options.

Scene Assistant Tab

The Scene Assistant scaffolds a Unity scene with all required multiplayer GameObjects. Settings are stored in Definitions/{Name}/SceneAssistantSettings.asset — created automatically when you open the tab.

ConnectionManager Prefab Status

A banner at the top shows whether a ConnectionManager.prefab exists. Scene buttons work either way — the prefab is preferred, but a raw GameObject is added via reflection if the prefab does not yet exist.

Scene Setup

ControlDescription
Scene NameFilename for the generated scene. Default: GameScene. Saved as Definitions/{Name}/{SceneName}.unity.
Create Multiplayer SceneCreates a new empty scene with a Main Camera, ConnectionManager GameObject, EventDispatcher GameObject (if toggled), and a NetworkManager empty GameObject. Prompts to save unsaved changes first.
Add to Existing SceneAdds only the ConnectionManager (and EventDispatcher if toggled) to the currently open scene. If a ConnectionManager is already present, a confirmation dialog asks before adding a second one.

Event Dispatcher Toggle

The Add Event Dispatcher toggle controls whether a NetCrafterEventDispatcher GameObject is included when a scene is created or patched. See the Event Dispatcher section for the full API.

Player Spawning

FieldDescription
Spawn ModeAuto or Manual — stored for future runtime use
Player PrefabProject reference to your player prefab asset
Spawn PointsA list of Vector3 world positions
  • Spawn point list controls — one row per point with a Remove button. Remove deletes that entry and renames any SpawnPoint_N children in the active scene to stay in sequence.
  • + Add Spawn Point — appends a new point at (0, 0, 0).
  • Place Spawn Points in Scene — creates or updates a SpawnPoints parent GameObject in the active scene. Each child is named SpawnPoint_0, SpawnPoint_1, … and carries a NetCrafterSpawnPointGizmo that draws a green wire sphere with a Scene view label. Button is disabled when no spawn points are defined.
  • Place Player Prefab — instantiates the assigned player prefab at spawnPoints[0] (or Vector3.zero if no points are defined), registers the action with undo, and selects the new GameObject. Disabled when no prefab is assigned.

When you click Create Multiplayer Scene and spawn points are already defined, the SpawnPoints hierarchy is placed in the new scene automatically — no extra button click needed.

Additive Scenes

Each entry in the list has a SceneAsset picker (path stored as a string in the asset), an Async toggle, and a Remove button.

Generate Scene Loader — writes NetCrafterSceneLoader.cs to Generated/Client/ alongside the SmartFoxConnectionManager. The file contains an IEnumerator Start() that loads each scene in list order. Re-generate any time the list changes; the file is overwritten.

All additive scenes must be added to File → Build Settings before building. Missing scenes cause runtime errors.

MMO Map Bounds

The MMO fields displayed here are read from and written to SmartFoxSettings.asset — the same asset the Config Generator tab uses. Editing here is equivalent to editing in Settings → SmartFox Settings.

Visualise Bounds in Scene — creates or updates an MMOBounds GameObject with a NetCrafterMMOBoundsGizmo component. The gizmo holds a live reference to SmartFoxSettings, so the viewport rectangles update automatically when you change a bound value.

Gizmo elementColourRepresents
Outer wire rectangleCyanFull map boundary on the XZ plane
Inner wire rectangleYellowAOI (Area of Interest) centred at origin
Corner labelsCyan(X, Z) min and max coordinates
AOI labelYellowAOI: W × H

Scene Events Tab

Binds SFS3 ServerToClient network events to scene-level UnityEvent hooks without writing code.

Setup

  1. The tab discovers all ServerToClient GameplayMessageDefinition assets in the current schema and displays one binding entry per event.
  2. Click Add Router to Scene to create a SceneEventRouter GameObject in the active scene. A second click is disabled — only one router per scene.
  3. Wire each event's On Received UnityEvent in the Inspector-style UI. Bindings are serialized into the scene and survive save/reopen.
  4. The enabled toggle on each entry silences that binding at runtime without removing it.

How It Works at Runtime

NetCrafterSceneEventRouter subscribes to NetCrafterEventDispatcher in Start(). When an event fires, the router stores the payload in an internal dictionary and calls onReceived.Invoke(). To read the event payload in your handler:

C# · read last payload in a UnityEvent handler
var ev = (ChatBroadcastEvent)
    NetCrafterSceneEventRouter.Instance.GetLastPayload("ChatBroadcast");

A HelpBox below each event's UnityEvent shows the exact cast pattern for that event type.

Orphaned Bindings

If an event is renamed or removed from the schema, its binding moves to an Orphaned Bindings section at the bottom of the tab with a warning and a Remove button.

Event Dispatcher#

NetCrafterEventDispatcher is a runtime MonoBehaviour that ships with NetCrafter (Scripts/NetCrafterEventDispatcher.cs). It is not generated — it is a permanent part of the package available to any script in your project.

Why It Exists

The generated SmartFoxConnectionManager routes all SFS3 extension responses through a private OnExtensionResponse switch. Traditionally, to intercept events you would either subclass the generated file or edit it directly — both approaches break on the next Generate run. NetCrafterEventDispatcher provides an alternative: a string-keyed publish–subscribe bus that any MonoBehaviour can subscribe to without touching the generated code.

Adding It to a Scene

Enable Add Event Dispatcher in Scenes → Scene Assistant, then use Create Multiplayer Scene or Add to Existing Scene. The dispatcher is added as a separate EventDispatcher GameObject with DontDestroyOnLoad.

To add it manually: create a GameObject and attach NetCrafterEventDispatcher to it.

API

C# · subscribe and dispatch
// Register a callback for a server event
NetCrafterEventDispatcher.Instance.Subscribe("ChatBroadcast", OnChatBroadcastReceived);

// Deregister — call this in OnDisable or OnDestroy
NetCrafterEventDispatcher.Instance.Unsubscribe("ChatBroadcast", OnChatBroadcastReceived);

// The callback receives the already-deserialised typed event object as object
private void OnChatBroadcastReceived(object payload)
{
    var ev = (ChatBroadcastEvent)payload;
    chatWindow.AddMessage(ev.senderName, ev.message);
}

How the Dispatcher Integrates with Generated Code

Every switch case in the generated SmartFoxConnectionManager.OnExtensionResponse calls Dispatch before the stub handler. Both always fire — the dispatcher fires first so subscribers receive the event, then the On{Event} stub runs so any direct override in a subclass also executes.

C# · generated switch case
case "ChatBroadcast":
{
    var ev = ChatBroadcastEvent.FromSFSObject(data);
    NetCrafterEventDispatcher.Instance?.Dispatch("ChatBroadcast", ev);
    OnChatBroadcast(ev);  // stub — override in a subclass if preferred
    break;
}

Exception Isolation

Each subscriber callback is wrapped in an individual try/catch. One failing subscriber cannot block other subscribers from receiving the same event. The error is logged to the Unity console with the command name and full stack trace.

Lifetime and Cleanup

NetCrafterEventDispatcher is a singleton with DontDestroyOnLoad. Always call Unsubscribe in OnDisable or OnDestroy — failing to do so leaves a dangling reference and the callback will continue to fire for the lifetime of the dispatcher.

Sync Rule Runtime#

The Sync Rule Runtime automatically synchronises component values between clients according to the rules defined in the Sync Rules tab. It ships as three permanent runtime MonoBehaviours in Scripts/ — nothing is generated per-schema.

Components

ScriptRole
NetCrafterSyncManagerSingleton. Owns the object registry, routes incoming sync payloads to the correct binding, and sends outgoing data via INetCrafterConnection.
NetCrafterSyncBindingPlaced on each networked GameObject. Reads a SyncRuleDefinition from the Inspector, drives the tick loop, builds and sends payloads (if hasAuthority), or applies incoming payloads (if not).
INetCrafterConnectionInterface implemented by the generated SmartFoxConnectionManager. Decouples the sync runtime from the generated namespace.

Setting Up Sync in a Scene

  1. Add NetCrafterSyncManager to a persistent GameObject in the scene. It auto-detects the SmartFoxConnectionManager at Start.
  2. Add NetCrafterSyncBinding to each networked GameObject.
  3. In the Inspector, assign: Rule (drag a SyncRuleDefinition asset), Object Id (a unique integer for this object in the session), and Has Authority (check for the local player, leave unchecked for remote players).

Authority and Object ID

  • hasAuthority = true (local player): The binding sends data to the server on every tick according to the sync mode. The server is expected to relay this to other clients.
  • hasAuthority = false (remote players): The binding subscribes to incoming sync events via NetCrafterEventDispatcher and applies received values to its component.

objectId must be unique per session and agreed between sender and receiver. NetCrafter does not assign or manage IDs. The SFS3 User.Id is a natural choice for player objects.

Data Flow

Outbound (local player → server):

Data flow — outbound
NetCrafterSyncBinding.FixedUpdate  →  BuildPayload (SFSObject)
  →  NetCrafterSyncManager.TrySendSync
    →  INetCrafterConnection.SendExtensionRequest
      →  sfs.Send(ExtensionRequest("__nc_sync_{RuleName}", payload))

Inbound (server → remote player binding):

Data flow — inbound
SFS3 EXTENSION_RESPONSE "__nc_sync_{RuleName}"
  →  SmartFoxConnectionManager default case
    →  NetCrafterEventDispatcher.Dispatch(cmd, (object)data)
      →  NetCrafterSyncManager callback (ISFSObject payload)
        →  bindings[data.GetInt("id")].ApplyIncoming(data)
          →  transform.position = new Vector3(x, y, z)

Wire Format

All sync commands use the prefix __nc_sync_ followed by the rule name. The payload is an SFSObject with:

FieldTypeDescription
"id"intobjectId of the sending binding
"x", "y", "z"floatVector3 components (position, scale, velocity)
"w"floatQuaternion W component (rotation only)

Payload Convention

Sync callbacks receive a raw ISFSObject as the object payload — not a typed event class. This is different from normal event callbacks (which receive a deserialised event object). See the default case in the generated SmartFoxConnectionManager.

What Is NOT Handled

  • Interpolation / smoothing: values are applied directly. Use Vector3.Lerp or similar in game code if smoothing is needed.
  • Ownership transfer: hasAuthority is set in the Inspector and does not change at runtime.
  • Bandwidth budgeting: tick rate is controlled by Unity's FixedUpdate rate and the interval field.
  • Server relay logic: NetCrafter does not generate or manage the server-side handler that relays sync packets to other players.

Coming Soon#

Features visible in the UI and their current implementation status.

FeatureStatus
Server Code Generation (Code → Server Code)Implemented — Generates Java SFS3 extension, handlers, models, and pom.xml. Build and deploy run from the Deploy to SFS3 button, not a generated script.
Config Generator (Code → Config Generator)Implemented — Generates {zoneName}.zone.xml from SmartFox Settings.
Scene Assistant — scene creationImplemented — Create Multiplayer Scene and Add to Existing Scene are functional.
Scene Assistant — player spawningImplemented — Place Player Prefab and Place Spawn Points in Scene are functional.
Scene Assistant — additive scenesImplemented — SceneAsset list + Generate Scene Loader button.
Scene Assistant — MMO map boundsImplemented — Live gizmo wired to SmartFoxSettings.
Prefab Generator — ConnectionManagerImplemented
Prefab Generator — Player / Chat UI / NPCComing. Sections visible in the UI but greyed out.
Scene Events (Scenes → Scene Events)Implemented — NetCrafterSceneEventRouter + visual UnityEvent binding editor.
Sync Rule RuntimeImplemented — NetCrafterSyncManager and NetCrafterSyncBinding ship in Scripts/.
Partial classes / Advanced syncComing.