livekit/client-sdk-unity-web
Acerca de
Official LiveKit SDK for Unity WebGL
Diseño y multimediaCrecimiento de estrellas medido
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- 0
- in 1 month
- 0
Cambios netos en períodos que se solapan, no totales diarios. Los datos no disponibles se dejan en blanco. Las estrellas indican interés, no calidad.
README.md
Original
LiveKit Unity SDK
Use this SDK to add realtime video, audio and data features to your Unity (WebGL) app. By connecting to LiveKit Cloud or a self-hosted server, you can quickly build applications such as multi-modal AI, live streaming, or video calls with just a few lines of code.
[!IMPORTANT] If you're building Voice AI, LiveKit Agents is the SDK for code-first realtime voice agents. STT, LLM, TTS, turn detection, expressive speech, keyterm accuracy, tool usage, and telephony all come bundled in the framework. It's available in both Python and Node.js.
LiveKit Agents is a great fit for customer support, healthcare, financial services, and outbound calling. Try the live demos.
# agent.py from livekit import agents from livekit.agents import Agent, AgentServer, AgentSession, STTContextOptions, TurnHandlingOptions, inference server = AgentServer() @server.rtc_session(agent_name="my-agent") async def my_agent(ctx: agents.JobContext): session = AgentSession( stt=inference.STT(model="deepgram/nova-3", language="multi"), llm=inference.LLM(model="google/gemma-4-31b-it"), tts=inference.TTS(model="inworld/inworld-tts-2", voice="Ashley"), turn_handling=TurnHandlingOptions(turn_detection=inference.TurnDetector()), stt_context_options=STTContextOptions(keyterms=["LiveKit", "Acme Corp"]), expressive=True, ) await session.start(room=ctx.room, agent=Agent(instructions="You are a helpful voice AI assistant.")) await session.generate_reply(instructions="Greet the user and offer your assistance.") if __name__ == "__main__": agents.cli.run_app(server)Models come from LiveKit Inference with no per-provider API keys, and LiveKit Cloud handles deployment and observability. Visit the docs for more info at docs.livekit.io/agents.
Using a coding agent? Install the LiveKit skill with
npx skills add livekit/agent-skillsand add the docs MCP athttps://docs.livekit.io/mcp/(see coding agent support).
Docs
Docs and guides at https://docs.livekit.io
Installation :
Follow this unity tutorial using the https://github.com/livekit/client-sdk-unity-web.git link.
You can then directly import the samples into the package manager.
Usage :
Write your application in C#. See the ExampleRoom sample.
Debugging
To display internal LiveKit logs, add LK DEBUG to define symbols
Examples
For a complete example, look at our demo
Connecting to a room
public class MyObject : MonoBehaviour
{
public Room Room;
IEnumerator Start()
{
Room = new Room();
var c = Room.Connect("<livekit-url>", "<your-token>");
yield return c;
if (!c.IsError) {
// Connected
}
}
}
Publishing video & audio
yield return Room.LocalParticipant.EnableCameraAndMicrophone();
Display a video on a RawImage
RawImage image = GetComponent<RawImage>();
Room.TrackSubscribed += (track, publication, participant) =>
{
if(track.Kind == TrackKind.Video)
{
var video = track.Attach() as HTMLVideoElement;
video.VideoReceived += tex =>
{
// VideoReceived is called every time the video resolution changes
image.texture = tex;
};
}
};
Sending/Receiving data
Room.DataReceived += (data, participant, kind, topic) =>
{
Debug.Log("Received data : " + Encoding.ASCII.GetString(data));
};
yield return Room.LocalParticipant.PublishData(
Encoding.ASCII.GetBytes("This is as test"),
reliable: true,
destinationIdentities: null,
topic: null
);
Agent Communication
For agent voice (audio/video) communication, follow the basic publish/subscribe examples above. This section focuses on agent messaging, state, and transcription.
1) Send message to an agent (AgentSendTextExample)
Sends a message to a specific participant identity on lk.chat.
public class AgentSendTextExample : MonoBehaviour
{
public Room Room;
public string AgentIdentity;
public IEnumerator SendToAgent(string message)
{
var send = Room.LocalParticipant.SendText(
text: message,
destinationIdentities: new[] { AgentIdentity },
topic: "lk.chat"
);
yield return send;
}
}
2) Listen for agent transcription (AgentTranscriptionExample)
Attach transcription listener when the matching agent participant connects.
public class AgentTranscriptionExample : MonoBehaviour
{
public Room Room;
public string AgentIdentity;
private RemoteParticipant _agent;
// Room.ParticipantConnected event listener
public void OnAgentConnected(RemoteParticipant participant)
{
if (participant.Identity != AgentIdentity) return;
_agent = participant;
_agent.TranscriptionReceived += OnAgentTranscriptionReceived;
}
// Room.ParticipantDisconnected event listener
public void OnAgentDisconnected(RemoteParticipant participant)
{
if (_agent != null && participant.Identity == _agent.Identity)
{
_agent.TranscriptionReceived -= OnAgentTranscriptionReceived;
_agent = null;
}
}
private void OnAgentTranscriptionReceived(List<TranscriptionSegment> segments, TrackPublication publication)
{
foreach (var segment in segments)
{
Debug.Log($"Agent with identity {_agent.Identity} transcription received: '{segment.Text}'");
}
}
}
3) Listen for agent state changes (AgentAttributesChangedExample)
Uses Room.AttributesChanged and reads lk.agent.state.
public class AgentAttributesChangedExample : MonoBehaviour
{
public Room Room;
public string AgentIdentity;
private RemoteParticipant _agent;
// Room.ParticipantConnected event listener
public void OnAgentConnected(RemoteParticipant participant)
{
if (participant.Identity != AgentIdentity) return;
_agent = participant;
Room.AttributesChanged += OnAgentAttributesChanged;
}
// Room.ParticipantDisconnected event listener
public void OnAgentDisconnected(RemoteParticipant participant)
{
if (_agent != null && participant.Identity == _agent.Identity)
{
Room.AttributesChanged -= OnAgentAttributesChanged;
_agent = null;
}
}
public void OnAgentAttributesChanged(Participant participant, IReadOnlyDictionary<string, string> changedAttributes)
{
if (_agent == null || participant.Identity != _agent.Identity) return;
if (changedAttributes.TryGetValue("lk.agent.state", out var state))
{
Debug.Log($"Agent with identity {participant.Identity} is now {state}");
}
}
}
| LiveKit Ecosystem | |
|---|---|
| Agents SDKs | Python · Node.js |
| LiveKit SDKs | Browser · Swift · Android · Flutter · React Native · Rust · Node.js · Python · Unity · Unity (WebGL) · ESP32 · C++ |
| Robotics | Portal · Portal for ROS |
| Starter Apps | Python Agent · TypeScript Agent · React App · SwiftUI App · Android App · Flutter App · React Native App · Web Embed |
| UI Components | React · Android Compose · SwiftUI · Flutter |
| Server APIs | Node.js · Golang · Ruby · Java/Kotlin · Python · Rust · PHP (community) · .NET (community) |
| Resources | Docs · Docs MCP Server · CLI · LiveKit Cloud |
| LiveKit Server OSS | LiveKit server · Egress · Ingress · SIP |
| Community | Developer Community · Slack · X · YouTube |
Explorar proyectos relacionados
Cargando…