ScriptingExamples

Examples

Complete, copyable scripts for common world and prop features, from a spinning cube to a networked scoreboard.

Each example is a whole script with the scene setup it needs. They build on each other: start with Basics if you are new to Basis scripting, then Synced Toggle for your first networked script.

ExampleShows
BasicsA Cilbox script, inspector fields, Update, a UI button.
Synced ToggleA button that turns something on or off for everyone, including late joiners.
ScoreboardA synced score kept by one owner, with other players asking the owner to add points.
Pickup GunA synced pickup that fires, with the shot shown to everyone.
Touch ButtonPressing a button with your finger in VR.
SeatsSeating, turning and ejecting players from a script.
Zones and TeleportersDetecting the local player in an area, teleporting, trampolines and lobby counts.
NPC FollowA NavMesh agent simulated by one owner and sent to everyone.
Image LoadingShowing a picture from a URL on a sign.
MinimapA top down camera following the local player onto a render texture.
PersistenceSaving and loading a player's progress.
Settings TabAdding world options to the player's menu.
Day Night CycleA sun on the shared server clock, no networking needed.
Round TimerA synced countdown from one message per round.
Trivia QuizQuestions from a JSON file with the current question synced.
Server Best TimePer player saves on the server with BasisServerStorageShim.
Staff DoorA door for admins and moderators that updates live.
Voice StagePlaying a speaker's voice from stage speakers.
Drawing BoardA shared whiteboard with compressed late joiner snapshots.
Random LootThe same random item for everyone with no messages.
ElevatorA shared moving platform from one synced number.
Tail ReactionAn avatar reacting when its jiggle bones are grabbed.
Hand FlashlightPinning an object to the hand without lag.
Desktop and VR InputOne script for mouse clicks and VR triggers.
Localized SignText in the player's language.
Performance ScalerCutting effects when the frame rate drops.
Server PortalSending players to another server.
Boids200 birds animated with one batched call per frame.

All examples are also in the Unity editor under Basis > Creator Guide, where each code block has a copy button.

Edit on GitHub

Last updated on