Examples
Documentation version: 0.3.6
The Example/ folder in the LCGUdonSharp repository contains runnable scenes and scripts for every feature. Each example .cs ships with its same-named UdonSharpProgramAsset; the example .asmdef also ships with a separate U# assembly-definition asset so the compiler can discover it.
| Folder | Covers |
|---|---|
Example/AsyncAwait | Async lowering — Task.Yield(), Task.Delay, string/image/video awaits, GPU readback, serialization, Creator Economy. |
Example/Interfaces | Interface MVP — INumberOperation with Add/Multiply implementations invoked through the interface. Input 10 → 15, 30. |
Example/Networking | Native and LCG lamps, packet fields/methods, zone-scoped moving cubes, and opt-in native/LCG high-bandwidth load generators. |
Example/GenericRestrictions | Collections and restrictions — runnable collection/JSON/binary examples plus rejected open generics, generic heap objects, interfaces, multiple bases, and Task<T> notes. |
Example/ExtendedLanguage | Extended C# — try/catch/finally, ref/out, closed generics & interface diamonds, LINQ closures, dynamic, Span<T>. |
Quick start: run an example
- Fix any unrelated C# compilation errors and let Unity finish compiling.
- Open
Example/TestLCGUdonSharp.unity, or add an example component to a GameObject in your own scene — every example.csalready ships with its same-namedUdonSharpProgramAsset. - Enter Play Mode and inspect the Console.
Networking prefabs in 0.3.6
NetworkExamples.prefabwires a native synced lamp outside the zone, an LCG packet lamp inside it, and an LCG-synced moving cube. Use it for two-client checks of re-entry, late join, owner departure and current-state snapshots.HighBandwidthExamples.prefabcontains two stopped-by-default load generators:NativeHighBandwidthExamplesends a Manual[UdonSynced] byte[], whileLCGHighBandwidthExampledrives up to 32 converted object-sync cubes through the bounded motion queue.- The LCG load dashboard shows locally produced samples, locally owned objects, pending motion, dispatched batches and the last batch size. These counters are diagnostic and do not prove remote delivery or network throughput.
Example/Networking/README.th.mdprovides Thai setup and two-client validation instructions.
Cross-client delivery, late join, ownership contention, bandwidth and FPS require VRChat Build & Test with multiple clients; single-player ClientSim only verifies compilation, wiring and local interaction.
:::tip Program assets and assembly registration
Every U# .cs needs a same-named UdonSharpProgramAsset. Use Assets > Create > U# Script so Unity creates both files together. Scripts outside Assembly-CSharp also need their .asmdef registered through Assets > Create > U# Assembly Definition.
:::