by Pivec Labs
Getting Started Voice & Video

Getting Started

From a NetCrafter Pro project to a working video call between two copies of your game — first on your own machine or LAN, then over the internet.

01

1. Install the WebRTC package#

Open Tools → Pivec Labs → NetCrafter Pro → Live → Setup & Demos and click Install com.unity.webrtc 3.0.0 (or Window → Package Manager → + → Add package by name → com.unity.webrtc). Unity recompiles; the Live components and demos switch on automatically — they are guarded by the package's presence, so projects without it never see a compile error.

02

2. Add Live to your zone extension#

Live's server side is a Java class, NetCrafterLiveServer.java, that sits next to your generated extension and is registered by three lines in it. From this version on, Code → Server Code → Generate Server Code adds both automatically, and Deploy builds and copies the JAR as usual.

  1. Select your Definition, open Code → Server Code, click Generate Server Code, then Deploy.
  2. Restart SmartFoxServer — a running server does not reload a replaced JAR.

The Live → Setup & Demos tab shows for every Definition whether its server code includes Live.

Hand-written extensions

If your extension class is hand-written (it is not regenerated), click Add Live server code in the Setup tab to place NetCrafterLiveServer.java, then add the three lines from Templates/JavaExtension.tpl marked NetCrafter Live: the field, the registration loop in init(), and the two calls in your room-leave and disconnect handlers.

An extension built before Live existed doesn't answer Live's handshake. The client then reports server_outdated after a few seconds — regenerate, deploy and restart.

03

3. Try a demo on one machine#

  1. Make sure the Chat Definition's server code is deployed (step 2) and SmartFoxServer is running.
  2. Open Examples/Live/Scenes/LiveCallDemo.unity.
  3. Build it (File → Build Profiles) or enable Multiplayer Play Mode, so you have two copies running.
  4. In both: type a name, click Connect. Each joins the room and the room call; the other player appears in the grid.
  5. Hold Space (or the on-screen button) to talk.

On one machine or a LAN no TURN server is needed — the players reach each other directly.

One webcam, two copies

Most webcams can be opened by one program at a time. When both copies run on one PC, the second may get no camera picture — that is expected; voice still works. Test video between two machines.

04

4. Make it work over the internet#

Between different networks a direct connection often works, but not always. For the cases where it doesn't, set up a TURN server once: Live → TURN Server Wizard installs coturn on a Linux server (your SFS3 server is ideal) and writes the Live settings into your extensions. The full walkthrough is in TURN Server Setup.

05

5. Add a call to your own scene#

Any scene that already has your Definition's ConnectionManager:

  1. Add NetCrafterLiveCall to a GameObject (Add Component → NetCrafter → Live → Live Call).
  2. Add NetCrafterLiveRoomLink to the same object — it joins the room's call as soon as your game joins its room.
  3. Show the video: subscribe to RemoteVideoAvailable / LocalVideoAvailable and put the textures on RawImages or materials.
csharp
using PivecLabs.Netcrafter.Live;
using UnityEngine;
using UnityEngine.UI;

public class MyVideoTiles : MonoBehaviour
{
    public NetCrafterLiveCall call;
    public RawImage myVideo;
    public RawImage[] others;          // up to 5

    void OnEnable()
    {
        call.LocalVideoAvailable += tex => myVideo.texture = tex;
        call.RemoteVideoAvailable += (userId, tex) => Refresh();
        call.ParticipantLeft += userId => Refresh();
        call.ErrorOccurred += (code, message) => Debug.LogWarning(code + ": " + message);
    }

    void Refresh()
    {
        int i = 0;
        foreach (int id in call.Participants)
        {
            if (id == call.LocalUserId || i >= others.Length) continue;
            others[i++].texture = call.GetRemoteVideo(id);
        }
        for (; i < others.Length; i++) others[i].texture = null;
    }
}

The Group Call tutorial goes through the demo's full UI; the API Reference lists everything.

06

6. Building for Mac, iOS and Android#

Live runs on Windows, macOS (Intel and Apple Silicon), Linux, iOS and Android. A few Player Settings matter:

PlatformPlayer SettingsNotes
macOS / iOSCamera Usage Description and Microphone Usage Description (Other Settings) — any short text, e.g. “Used for video calls”.Required. With the camera text empty Unity refuses to build (“WebCamTexture class is used but Camera Usage Description is empty”); with the microphone text empty the app gets no microphone. The OS asks the player for access on first use.
AndroidScripting Backend IL2CPP, Target Architectures ARM64, Internet Access: Require, Landscape orientation for the demos.Camera/microphone permissions are added by Unity and requested at runtime by Live. If remote video stays black on a device, tick Strip Video RTX Workaround on both sides.

Mac builds made on Windows: copy the .app to the Mac, then once in Terminal run chmod +x YourApp.app/Contents/MacOS/* and xattr -cr YourApp.app (Windows zips drop the executable flag; unsigned apps are quarantined), and right-click → Open the first time.

Phones on mobile data almost never connect directly — set up the TURN server before testing away from your Wi-Fi.