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 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
| Field | Description |
|---|---|
| Message Name | The base class name. A ClientToServer message generates {Name}Request.cs. A ServerToClient message generates {Name}Event.cs. |
| Direction | ClientToServer — 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). |
| Transport | Always ExtensionRequest for the current generator. Other transport types are reserved for future use. |
| Server Handler Name | The name that must match a Server Action's Handler Name. Validation will fail if no matching Server Action exists. |
| Fields | The data payload. Each field has a Name and a Type. |
Field Types
| Schema type | C# type | SFS3 wire format | Notes |
|---|---|---|---|
int | int | PutInt / GetInt | |
float | float | PutFloat / GetFloat | |
bool | bool | PutBool / GetBool | |
string | string | PutString / GetString | |
Vector2 | Vector2 | PutFloatArray (2 floats) | |
Vector3 | Vector3 | PutFloatArray (3 floats) | |
Quaternion | Quaternion | PutFloatArray (4 floats) | Edit asset YAML directly to use |
PlayerId | int | PutInt / GetInt | Semantic alias for player IDs |
ItemId | string | PutString / GetString | Semantic alias for item identifiers |
| ModelName | ModelName | PutSFSObject / nested ISFSObject | Edit 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.
| Field | Description |
|---|---|
| Handler Name | Must match the Server Handler Name on one or more messages or events. |
| Trigger Message | Optional reference to the message that triggers this action. |
| Logic Type | BroadcastAll, BroadcastAOI, SenderOnly, TargetUser, or Custom. Used for server code generation. |
| Custom Java Code | Freeform 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.
| Field | Description |
|---|---|
| Rule Name | Identifier for this rule. Also used as the network command suffix: __nc_sync_{RuleName}. |
| Sync Target | The component property to synchronise. See the table below. |
| Sync Mode | Always, OnChange, or Interval. See below. |
| Interval | Seconds between syncs when Sync Mode is Interval. Default: 0.05 (20 Hz). |
Sync Targets
| Target | Component | Property |
|---|---|---|
Transform_Position | Transform | position (world space) |
Transform_Rotation | Transform | rotation (world space quaternion) |
Transform_Scale | Transform | localScale |
Rigidbody_Velocity | Rigidbody | linearVelocity |
Rigidbody_AngularVelocity | Rigidbody | angularVelocity |
Sync Modes
| Mode | Behaviour |
|---|---|
Always | Sends every FixedUpdate. Use for values that change every frame (e.g. position of a moving character). |
OnChange | Sends 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. |
Interval | Sends 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
| Control | Action |
|---|---|
| Validate Definition | Runs the validator and shows a success dialog or opens the error window. Does not generate any files. |
| Preview JSON | Opens a read-only window showing the raw schema JSON that will be passed to the generator. |
| Generate All Files | Validates, then generates client code, server code, and config. |
| Client Only | Validates, then generates client C# files only. |
| Server Only | Validates, then runs the server generator (currently a stub — no files produced). |
| Open Output Folder | Reveals 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:
- Duplicate names — no two messages, events, or models may share a name; no message and model may share a name.
- Invalid field types — all field types must be a supported primitive or a declared model name.
- Missing handler references — every message and event must name a handler that exists in the Server Actions list.
- 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 tab | Shows |
|---|---|
| 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.
| Button | Action |
|---|---|
| Copy | Copies the file content to the clipboard |
| Open ↗ | Opens the file in the system default application |
| Normal / Diff | Toggles 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
- Set Extension Class and Extension Name in Settings → SmartFox Settings. Extension Class must be fully qualified (e.g.
com.company.game.MyExtension). - Set SFS3 Lib Path and SFS3 Extensions Path in Settings → Project Settings (Server Build Settings section).
- Click Generate Server Code — creates the Java project in
Definitions/{Name}/Generated/Server/. - Click Build JAR (mvn package) — compiles the project and produces
target/{ExtensionName}.jar. - Click Deploy to SFS3 — runs Maven and copies the JAR to your SFS3 extensions folder directly (no script file involved).
- Start (or restart) your SFS3 server and check the server log for
{ExtensionName}: {ExtensionClass} initialized.
Generated Files
| File | Description |
|---|---|
{ExtensionClass}.java | SFS3 extension entry point; registers all handlers in init() |
handlers/Handle{Message}.java | One handler per Server Action; reads params, builds response, sends |
models/{Model}.java | One model per Data Definition; toSFSObject() / fromSFSObject() helpers |
pom.xml | Maven 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):
<extension>
<name>MyGame</name>
<type>JAVA</type>
<file>com.mygame.MyGameExtension</file>
<reloadMode>AUTO</reloadMode>
</extension>
Coming Soon — Server Code
TODO comment generated; full MMO proximity API not yet wired.
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.
| Button | Action |
|---|---|
| Refresh Preview | Re-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.xml | Writes the zone config XML to Definitions/{Name}/Generated/Config/{zoneName}.zone.xml and calls AssetDatabase.Refresh(). Also reveals the file in Explorer. |
| Open Config Folder | Reveals 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
| Field | Default | Description |
|---|---|---|
| Host | localhost | Server hostname or IP address |
| TCP Port | 9977 | TCP port (SFS3 default is 9977, not 9933) |
| WebSocket Port | 9977 | WebSocket port (used if WebSocket transport is active) |
| Zone Name | BasicZone | Zone as defined in your server zones.xml |
| Auto-Reconnect | true | Reserved for future use |
| Debug Logging | true | Enables SFS3 client-side verbose logging |
Login
| Field | Default | Description |
|---|---|---|
| Login Mode | Guest | Guest: sends an empty username. UsernamePassword and Custom are reserved for future use. |
| Guest Name Prefix | Player_ | Prefix prepended to the auto-assigned guest name |
Extension
| Field | Default | Description |
|---|---|---|
| Extension Name | BasicExtension | Name of the SFS3 extension handling requests |
| Extension Class | com.piveclabs.BasicExtension | Fully qualified Java class name |
| Send Queue Size | 4096 | Bytes |
| Max Message Size | 32768 | Bytes |
MMO
| Field | Default | Description |
|---|---|---|
| Enable MMO Mode | true | Enables the SFS3 MMO API (proximity-based interest management) |
| Map Bounds | X: −50 to 50, Z: −50 to 50 | World-space boundary of the MMO map |
| View Area | Width: 20, Height: 20 | Proximity range for area-of-interest queries |
| Interest Mode | Grid | Grid, 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
| Field | Description |
|---|---|
| Use Custom Templates | When 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
| Field | Default | Description |
|---|---|---|
| Namespace | PivecLabs.Generated | C# namespace used in all generated files |
| Class Prefix | empty | Prepended to every generated class name |
| Class Suffix | empty | Appended to every generated class name |
Generation Behaviour
| Field | Default | Description |
|---|---|---|
| Overwrite Existing Files | true | When false, the generator skips files that already exist on disk |
| Show Summary After Build | true | Reserved — generation summary logging is always written to the Unity console |
Logging
| Field | Default | Description |
|---|---|---|
| Verbose Logging | false | Passes the flag to the generator; currently only affects console log output |
Experimental Features
| Field | Description |
|---|---|
| Enable Partial Class Support | Reserved — not yet wired to the generator |
| Enable Advanced Sync Rules | Reserved — 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.
Generate a player prefab from a base prefab, optionally adding NetworkIdentity, MovementSync, RotationSync, AnimationSync, and HealthSync components.
Generate a UI prefab in Minimal, Modern, or MMO-Style layouts.
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
| Control | Description |
|---|---|
| Scene Name | Filename for the generated scene. Default: GameScene. Saved as Definitions/{Name}/{SceneName}.unity. |
| Create Multiplayer Scene | Creates 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 Scene | Adds 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
| Field | Description |
|---|---|
| Spawn Mode | Auto or Manual — stored for future runtime use |
| Player Prefab | Project reference to your player prefab asset |
| Spawn Points | A 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_Nchildren 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
SpawnPointsparent GameObject in the active scene. Each child is namedSpawnPoint_0,SpawnPoint_1, … and carries aNetCrafterSpawnPointGizmothat 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](orVector3.zeroif 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 element | Colour | Represents |
|---|---|---|
| Outer wire rectangle | Cyan | Full map boundary on the XZ plane |
| Inner wire rectangle | Yellow | AOI (Area of Interest) centred at origin |
| Corner labels | Cyan | (X, Z) min and max coordinates |
| AOI label | Yellow | AOI: W × H |
Scene Events Tab
Binds SFS3 ServerToClient network events to scene-level UnityEvent hooks without writing code.
Setup
- The tab discovers all
ServerToClientGameplayMessageDefinitionassets in the current schema and displays one binding entry per event. - Click Add Router to Scene to create a
SceneEventRouterGameObject in the active scene. A second click is disabled — only one router per scene. - Wire each event's On Received UnityEvent in the Inspector-style UI. Bindings are serialized into the scene and survive save/reopen.
- 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:
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
// 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.
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
| Script | Role |
|---|---|
NetCrafterSyncManager | Singleton. Owns the object registry, routes incoming sync payloads to the correct binding, and sends outgoing data via INetCrafterConnection. |
NetCrafterSyncBinding | Placed 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). |
INetCrafterConnection | Interface implemented by the generated SmartFoxConnectionManager. Decouples the sync runtime from the generated namespace. |
Setting Up Sync in a Scene
- Add
NetCrafterSyncManagerto a persistent GameObject in the scene. It auto-detects theSmartFoxConnectionManageratStart. - Add
NetCrafterSyncBindingto each networked GameObject. - In the Inspector, assign: Rule (drag a
SyncRuleDefinitionasset), 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 viaNetCrafterEventDispatcherand 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):
NetCrafterSyncBinding.FixedUpdate → BuildPayload (SFSObject)
→ NetCrafterSyncManager.TrySendSync
→ INetCrafterConnection.SendExtensionRequest
→ sfs.Send(ExtensionRequest("__nc_sync_{RuleName}", payload))
Inbound (server → remote player binding):
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:
| Field | Type | Description |
|---|---|---|
"id" | int | objectId of the sending binding |
"x", "y", "z" | float | Vector3 components (position, scale, velocity) |
"w" | float | Quaternion 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.Lerpor similar in game code if smoothing is needed. - Ownership transfer:
hasAuthorityis set in the Inspector and does not change at runtime. - Bandwidth budgeting: tick rate is controlled by Unity's
FixedUpdaterate and theintervalfield. - 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.
| Feature | Status |
|---|---|
| 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 creation | Implemented — Create Multiplayer Scene and Add to Existing Scene are functional. |
| Scene Assistant — player spawning | Implemented — Place Player Prefab and Place Spawn Points in Scene are functional. |
| Scene Assistant — additive scenes | Implemented — SceneAsset list + Generate Scene Loader button. |
| Scene Assistant — MMO map bounds | Implemented — Live gizmo wired to SmartFoxSettings. |
| Prefab Generator — ConnectionManager | Implemented |
| Prefab Generator — Player / Chat UI / NPC | Coming. Sections visible in the UI but greyed out. |
| Scene Events (Scenes → Scene Events) | Implemented — NetCrafterSceneEventRouter + visual UnityEvent binding editor. |
| Sync Rule Runtime | Implemented — NetCrafterSyncManager and NetCrafterSyncBinding ship in Scripts/. |
| Partial classes / Advanced sync | Coming. |