### CameraInfoDisplay Example (UdonSharp) Source: https://github.com/vrchat-community/creator-docs/blob/main/Docs/docs/worlds/udon/vrc-graphics/vrc-camera-settings.md An example script demonstrating how to use `VRCCameraSettings` and the `OnVRCCameraSettingsChanged` event in UdonSharp. ```APIDOC ```cs using TMPro; using UdonSharp; using UnityEngine; using UnityEngine.UI; using VRC.SDK3.Rendering; ​ public class CameraInfoDisplay : UdonSharpBehaviour { [SerializeField] private TextMeshProUGUI info; void Start() { // call it once to initialize OnVRCCameraSettingsChanged(VRCCameraSettings.ScreenCamera); Debug.Log($ ``` -------------------------------- ### Get Screen Camera Info Source: https://github.com/vrchat-community/creator-docs/blob/main/Docs/docs/worlds/udon/vrc-graphics/vrc-camera-settings.md Initializes camera information on start and updates it when camera settings change. Ignores non-screen cameras. Handles potential null values for internalComponent and externalComponent. ```csharp using TMPro; using UdonSharp; using UnityEngine; using UnityEngine.UI; using VRC.SDK3.Rendering; public class CameraInfoDisplay : UdonSharpBehaviour { [SerializeField] private TextMeshProUGUI info; void Start() { // call it once to initialize OnVRCCameraSettingsChanged(VRCCameraSettings.ScreenCamera); Debug.Log($ ``` ```csharp Started CameraInfoDisplay at resolution of {VRCCameraSettings.ScreenCamera.PixelWidth}x{VRCCameraSettings.ScreenCamera.PixelHeight}"); Debug.Log($"The handheld photo camera is {(VRCCameraSettings.PhotoCamera.Active ? "enabled" : "disabled")}"); } // will be called if resolution or a couple other properties change public override void OnVRCCameraSettingsChanged(VRCCameraSettings camera) { // ignore handheld photo camera if (camera != VRCCameraSettings.ScreenCamera) return; info.text = $"{camera.PixelWidth}x{camera.PixelHeight} fov={camera.FieldOfView} frame={Time.frameCount}°"; } } ``` -------------------------------- ### Manual Sync Example: Toggling a Door Source: https://github.com/vrchat-community/creator-docs/blob/main/Docs/docs/worlds/udon/networking/variables.md This example demonstrates manual synchronization. When `ToggleDoor` is called, the `isDoorOpen` variable is updated and `RequestSerialization()` is called to send the new state to all players. ```csharp [SerializeField, UdonSynced] private bool isDoorOpen; public void ToggleDoor() { isDoorOpen = !isDoorOpen; RequestSerialization(); // Manually send update to all players } ``` -------------------------------- ### FFmpeg Command for Fast Start Source: https://github.com/vrchat-community/creator-docs/blob/main/Docs/docs/worlds/udon/video-players/index.md Use this command-line parameter with FFmpeg to enable 'fast start' for MP4 files. This optimizes videos for streaming by allowing playback to begin before the entire file is downloaded. ```bash ffmpeg -i input.mp4 -movflags +faststart output.mp4 ``` -------------------------------- ### YAML Front Matter Example Source: https://github.com/vrchat-community/creator-docs/blob/main/Docs/docs/contribute/syntax.md An example of front matter in YAML format, enclosed by triple dashes. ```yaml --- unlisted: true --- ``` -------------------------------- ### Getting an instance of a builder Source: https://github.com/vrchat-community/creator-docs/blob/main/Docs/docs/sdk/public-sdk-api.md This example shows how to get an instance of an avatar builder API by subscribing to the `OnSdkPanelEnable` event and using `TryGetBuilder`. This ensures the SDK window is open and the builder is registered before attempting to retrieve it. ```APIDOC ## Getting an instance of a builder Connecting to `OnSdkPanelEnable` will ensure that the SDK window was opened and the builders were registered. You can then use `TryGetBuilder` to get an instance of the builder you need. You can call `VRCSdkControlPanel.TryGetBuilder` at any point in time, but it will return false if the SDK window is not open or the builder you're trying to access is not available. ```csharp [InitializeOnLoadMethod] public static void RegisterSDKCallback() { VRCSdkControlPanel.OnSdkPanelEnable += AddBuildHook; } private IVRCSdkAvatarBuilderApi _builder; private static void AddBuildHook(object sender, EventArgs e) { VRCSdkControlPanel.TryGetBuilder(out _builder); } ``` ``` -------------------------------- ### MDX with BrowserWindow Component Source: https://github.com/vrchat-community/creator-docs/blob/main/Docs/docs/contribute/syntax.md An example of using the BrowserWindow component within MDX to display content. ```mdx ```mdx-code-block # Example page This is an example page with a title and some text. ```mdx-code-block ``` -------------------------------- ### Set and Get DataList Items with Shorthand Bracket Syntax Source: https://github.com/vrchat-community/creator-docs/blob/main/Docs/docs/worlds/udon/data-containers/data-lists.md Utilize bracket syntax for concise setting and getting of DataList items. This method is faster but less safe than TryGetValue, as it can halt execution on invalid operations. Use this only when you can guarantee the data's existence and type. ```csharp list[0] = 5; list[1] = 10; // This makes the assumption that index 0 and 1 will always contain integers. // This is a safe assumption to make since we set them just above in a controlled environment. // If the data is coming from an external source, we shouldn't make these assumptions! int sum = list[0].Int + list[1].Int; ``` -------------------------------- ### Register SDK Callback Source: https://github.com/vrchat-community/creator-docs/blob/main/Docs/docs/sdk/public-sdk-api.md Connects to OnSdkPanelEnable to ensure the SDK window is open and builders are registered. Use this to get an instance of the builder. ```csharp [InitializeOnLoadMethod] public static void RegisterSDKCallback() { VRCSdkControlPanel.OnSdkPanelEnable += AddBuildHook; } private IVRCSdkAvatarBuilderApi _builder; private static void AddBuildHook(object sender, EventArgs e) { VRCSdkControlPanel.TryGetBuilder(out _builder); } ``` -------------------------------- ### Building from script Source: https://github.com/vrchat-community/creator-docs/blob/main/Docs/docs/sdk/public-sdk-api.md This example shows how to initiate the build and test process for a selected avatar directly from a script using the `BuildAndTest` method. It includes error handling for potential exceptions during the build. ```APIDOC ## Building from script ```csharp [MenuItem("My Tools/Build Selected Avatar")] public static async void BuildSelectedAvatar() { var avatar = Selection.activeGameObject; if (!VRCSdkControlPanel.TryGetBuilder(out var builder)) return; try { await builder.BuildAndTest(avatar); } catch (Exception e) { Debug.LogError(e.Message); } } ``` ``` -------------------------------- ### get playerId Source: https://github.com/vrchat-community/creator-docs/blob/main/Docs/docs/worlds/udon/players/getting-players.md Gets the cached PlayerId of the current player. ```APIDOC ## get playerId ### Description Retrieves the cached PlayerId of the current player. If the ID has not been cached yet, it will call GetPlayerId to retrieve it. ### Method Static method call. ### Return Value int - The PlayerId of the current player. ``` -------------------------------- ### Running code before the build Source: https://github.com/vrchat-community/creator-docs/blob/main/Docs/docs/sdk/public-sdk-api.md This snippet demonstrates how to execute custom code just before the SDK build process begins by subscribing to the `OnSdkBuildStart` event. This event fires after validations and callbacks have passed. ```APIDOC ## Running code before the build `OnSdkBuildStart` runs right before the SDK kicks off the build process, but after validations and Build Request Callbacks have passed. ```csharp [InitializeOnLoadMethod] public static void RegisterSDKCallback() { VRCSdkControlPanel.OnSdkPanelEnable += AddBuildHook; } private static void AddBuildHook(object sender, EventArgs e) { if (VRCSdkControlPanel.TryGetBuilder(out var builder)) { builder.OnSdkBuildStart += OnBuildStarted; } } private static void OnBuildStarted(object sender, object target) { Debug.Log("Building " + ((GameObject) target).name); } ``` ``` -------------------------------- ### Implement IPreprocessCallbackBehaviour for Pre-Build Logic Source: https://github.com/vrchat-community/creator-docs/blob/main/Docs/docs/sdk/build-pipeline-callbacks-and-interfaces.md Use this interface to execute custom code before the build process begins. Place scripts implementing this on scene objects if scene references are needed. Note that this does not bypass SDK validation; use IEditorOnly as well if scripts are on the avatar itself. ```csharp public void OnPreprocess() { } public int PreprocessOrder { get; } ``` -------------------------------- ### GetPlayer Source: https://github.com/vrchat-community/creator-docs/blob/main/Docs/docs/worlds/udon/players/drones/drone-information.md Gets the owner of the Drone. ```APIDOC ## GetPlayer ### Description Gets the owner of the Drone. ### Output - `VRCPlayerApi`: The owning player object. ``` -------------------------------- ### Example Custom Inspector for UdonSharpBehaviour Source: https://github.com/vrchat-community/creator-docs/blob/main/Docs/docs/worlds/udon/udonsharp/editorscripting.md This example demonstrates a full custom inspector for a UdonSharpBehaviour. It includes necessary using statements wrapped in preprocessor directives, the UdonSharpGUI.DrawDefaultUdonSharpBehaviourHeader call, and custom field drawing with Undo handling. ```csharp using UnityEngine; using VRC.SDK3.Components; using VRC.SDKBase; using VRC.Udon; #if !COMPILER_UDONSHARP && UNITY_EDITOR // These using statements must be wrapped in this check to prevent issues on builds using UnityEditor; using UdonSharpEditor; #endif namespace UdonSharp.Examples.Inspectors { /// /// Example behaviour that has a custom inspector /// public class CustomInspectorBehaviour : UdonSharpBehaviour { public string stringVal; private void Update() { Debug.Log($ ``` -------------------------------- ### Enable Legacy Locomotion (Not Recommended) Source: https://github.com/vrchat-community/creator-docs/blob/main/Docs/docs/worlds/udon/players/index.md Enables legacy locomotion for a player, mimicking older SDK2 movement. This setting persists until the user leaves the world. Use with caution as it is not recommended. ```text UseLegacyLocomotion ``` -------------------------------- ### List Top-Level Folders on Device with ADB Source: https://github.com/vrchat-community/creator-docs/blob/main/Docs/docs/platforms/android/build-test-mobile.md This command helps confirm ADB connectivity by listing directories on the connected device. ```bash adb shell ls ``` -------------------------------- ### GetPlayerId Source: https://github.com/vrchat-community/creator-docs/blob/main/Docs/docs/worlds/udon/players/getting-players.md Gets the Network Id of the player. ```APIDOC ## GetPlayerId ### Description Retrieves the Network Id of the player. ### Method Static method call. ### Return Value int - The Network Id of the player. ``` -------------------------------- ### Download String with Custom Text Encoding Source: https://github.com/vrchat-community/creator-docs/blob/main/Docs/docs/worlds/udon/string-loading.md This example demonstrates how to download a string from a URL and then decode the raw bytes using both UTF8 and ASCII encodings. It logs the results to the console. Ensure the URL is accessible and trusted. ```csharp using System.Text; using UdonSharp; using UnityEngine; using VRC.SDK3.StringLoading; using VRC.SDKBase; using VRC.Udon.Common.Interfaces; public class ResultBytesExample : UdonSharpBehaviour { [SerializeField] private VRCUrl url; void Start() { VRCStringDownloader.LoadUrl(url, (IUdonEventReceiver)this); } public override void OnStringLoadSuccess(IVRCStringDownload result) { string resultAsUTF8 = result.Result; byte[] resultAsBytes = result.ResultBytes; string resultAsASCII = Encoding.ASCII.GetString(resultAsBytes); Debug.Log($ ``` -------------------------------- ### GetRotation Source: https://github.com/vrchat-community/creator-docs/blob/main/Docs/docs/worlds/udon/players/drones/drone-information.md Gets the rotation of the Drone in world space. ```APIDOC ## GetRotation ### Description Gets the rotation of the Drone. ### Output - `Quaternion`: The drone's rotation in world space. ``` -------------------------------- ### GetPlayerCount Source: https://github.com/vrchat-community/creator-docs/blob/main/Docs/docs/worlds/udon/players/getting-players.md Gets the current number of players in the instance. ```APIDOC ## GetPlayerCount ### Description Returns the total number of players currently in the instance. ### Method Static method call. ### Return Value int - The number of players in the instance. ``` -------------------------------- ### GetPosition Source: https://github.com/vrchat-community/creator-docs/blob/main/Docs/docs/worlds/udon/players/drones/drone-information.md Gets the position of the Drone in world space. ```APIDOC ## GetPosition ### Description Gets the position of the Drone. ### Output - `Vector3`: The drone's position in world space. ``` -------------------------------- ### Register SDK Callback and Add Build Hook Source: https://github.com/vrchat-community/creator-docs/blob/main/Docs/docs/sdk/public-sdk-api.md Runs code before the SDK build process starts, after validations and Build Request Callbacks. It subscribes to OnSdkBuildStart to execute custom logic. ```csharp [InitializeOnLoadMethod] public static void RegisterSDKCallback() { VRCSdkControlPanel.OnSdkPanelEnable += AddBuildHook; } private static void AddBuildHook(object sender, EventArgs e) { if (VRCSdkControlPanel.TryGetBuilder(out var builder)) { builder.OnSdkBuildStart += OnBuildStarted; } } private static void OnBuildStarted(object sender, object target) { Debug.Log("Building " + ((GameObject) target).name); } ``` -------------------------------- ### IsDeployed Source: https://github.com/vrchat-community/creator-docs/blob/main/Docs/docs/worlds/udon/players/drones/drone-information.md Get whether the Drone is deployed in the world. ```APIDOC ## IsDeployed ### Description Get whether the Drone is deployed in the world. ### Output - `bool`: Whether the drone is deployed. ``` -------------------------------- ### Udon Runtime Error Example Source: https://github.com/vrchat-community/creator-docs/blob/main/Docs/docs/worlds/udon/debugging-udon-projects.md This is an example of a Udon runtime error log. It indicates an exception occurred during Udon execution, causing the UdonBehaviour to halt. The detailed message helps pinpoint the specific function call and the underlying .NET exception, such as a `NullReferenceException`. ```log 2020.08.28 17:40:51 Error - [UdonBehaviour] An exception occurred during Udon execution, this UdonBehaviour will be halted. VRC.Udon.VM.UdonVMException: An exception occurred in an UdonVM, execution will be halted. ---> VRC.Udon.VM.UdonVMException: An exception occurred during EXTERN to 'VRCSDK3VideoComponentsBaseBaseVRCVideoPlayer.__GetTime__SystemSingle'. ---> System.NullReferenceException: Object reference not set to an instance of an object. at VRC.SDK3.Internal.Video.Components.AVPro.AVProVideoPlayerInternal.GetTime () [0x00000] in <00000000000000000000000000000000>:0 at VRC.Udon.Wrapper.Modules.ExternVRCSDK3VideoComponentsBaseBaseVRCVideoPlayer.__GetTime__SystemSingle (VRC.Udon.Common.Interfaces.IUdonHeap heap, System.UInt32[] parameterAddresses) [0x00000] in <00000000000000000000000000000000>:0 ``` -------------------------------- ### Add Source: https://github.com/vrchat-community/creator-docs/blob/main/Docs/docs/worlds/udon/data-containers/data-dictionaries.md Adds a key-value pair to the dictionary. Throws an exception if the key already exists, making it suitable for initialization. ```APIDOC ## Add ### Description Adds the value at the specified key. Throws an exception if the key already exists. This is useful for initialization because it will cause a compile error, but it's not recommended for normal usage where it could cause a runtime error and halt your UdonBehaviour. ### Input - DataToken key - DataToken value ``` -------------------------------- ### GetVelocity Source: https://github.com/vrchat-community/creator-docs/blob/main/Docs/docs/worlds/udon/players/drones/drone-information.md Get the speed and direction of the drone's movement. ```APIDOC ## GetVelocity ### Description Get the speed and direction of the drone's movement. ### Output - `Vector3 velocity`: The drone's velocity in world space. ``` -------------------------------- ### Enable Udon Debugging via Steam Launch Options Source: https://github.com/vrchat-community/creator-docs/blob/main/Docs/docs/worlds/udon/debugging-udon-projects.md Configure Steam launch options for VRChat to automatically enable the Debug GUI and Udon debugging features every time the game is launched through Steam. ```steam --enable-debug-gui --enable-udon-debug-logging ``` -------------------------------- ### Store.OpenWorldStorePage Source: https://github.com/vrchat-community/creator-docs/blob/main/Docs/docs/economy/sdk/udon-documentation.md Opens the store page for the current world, if one exists. ```APIDOC ## Store.OpenWorldStorePage ### Description Opens a the world store page of the current world, if it has one. ``` -------------------------------- ### VRCPlayerApi.GetPlayerObjects Source: https://github.com/vrchat-community/creator-docs/blob/main/Docs/docs/worlds/udon/persistence/player-object.md Utility wrapper to get all PlayerObjects associated with the provided player. ```APIDOC ## VRCPlayerApi.GetPlayerObjects ### Description Returns an array of all the PlayerObjects associated with the provided player. ### Method `VRCPlayerApi.GetPlayerObjects()` ### Output - **objects** (GameObject[]) - An array of GameObjects representing the player's PlayerObjects. ``` -------------------------------- ### Direct Data Token Access with Shorthand Syntax Source: https://github.com/vrchat-community/creator-docs/blob/main/Docs/docs/worlds/udon/data-containers/data-tokens.md When you have full control over the data and are certain of its type, you can use shorthand bracket syntax for direct access. This is not recommended for data from external sources due to potential type mismatches. ```csharp dictionary["A"] = 5; dictionary["B"] = 10; // This makes the assumption that A and B will always contain integers. // This is a safe assumption to make since we set them just above in a controlled environment. // If the data is coming from an external source, we shouldn't make these assumptions! int sum = dictionary["A"].Int + dictionary["B"].Int; ``` -------------------------------- ### Udon Graph Quick Search Source: https://github.com/vrchat-community/creator-docs/blob/main/Docs/docs/worlds/udon/graph/index.md Press the Spacebar to open the Quick Search menu and type the first few letters of a class name to find and create nodes. This method is efficient if you are familiar with Unity's class names. ```Udon Graph Spacebar to open Quick Search, then type class name ``` -------------------------------- ### GetCurrentLanguage Source: https://github.com/vrchat-community/creator-docs/blob/main/Docs/docs/worlds/udon/players/index.md Gets the selected language of the local user in RFC 5646 format. ```APIDOC ## GetCurrentLanguage ### Description Gets the selected language of the local user. The value is formatted in the RFC 5646 syntax. ### Method *string* ### Example `en`, `ja`, `es`, `zh-CN` ``` -------------------------------- ### Store.OpenListing Source: https://github.com/vrchat-community/creator-docs/blob/main/Docs/docs/economy/sdk/udon-documentation.md Opens the purchase screen of a listing in VRChat's main menu. ```APIDOC ## Store.OpenListing ### Description Opens the purchase screen of a [listing](/economy/listings) in VRChat's main menu. You can open any of your activated listings, even if you didn't add it to your group [store](/economy/store) or world [store](/economy/store). ### Input - `string`: ID of the listing (i.e. `prod_00000000-0000-0000-0000-000000000000`) ``` -------------------------------- ### Get Player Simulation Time Source: https://github.com/vrchat-community/creator-docs/blob/main/Docs/docs/worlds/udon/players/index.md Retrieve the simulation time for a specific player. ```text SimulationTime ``` -------------------------------- ### TryGetRotation Source: https://github.com/vrchat-community/creator-docs/blob/main/Docs/docs/worlds/udon/players/drones/drone-information.md Try to get the rotation of the Drone. Returns a boolean indicating success. ```APIDOC ## TryGetRotation ### Description Try to get the rotation of the Drone. ### Out - `Quaternion rotation`: The rotation of the Drone in world space. ### Output - `bool`: indicates whether it was successful ```