### Unity Missing Dependencies List Example Source: https://docs.unity3d.com/6000.1/Documentation/Manual/index.html/Manual/ent-unpriv-install An example of a text file generated by the Unity Installer listing missing runtime dependencies required for a stable user experience. It includes the dependency name, download location, and the path to the local installer. ```text Dependency: Visual C++ 2010 runtime (x64) Download location: https://www.microsoft.com/en-ca/download/details.aspx?id=26999 Local Installer: C:\Users\nonadmin\AppData\Local\Unity 2023.1.0a5\MissingDependencies\vcredist_x64_2010.exe Dependency: Visual C++ 2013 runtime (x64) Download location: https://www.microsoft.com/en-ca/download/details.aspx?id=40784 Local Installer: C:\Users\nonadmin\AppData\Local\Unity 2023.1.0a5\MissingDependencies\vcredist_x64_2013.exe Dependency: Visual C++ 2015 runtime (x64) Download location: https://www.microsoft.com/en-ca/download/details.aspx?id=48145 Local Installer: C:\Users\nonadmin\AppData\Local\Unity 2023.1.0a5\MissingDependencies\vcredist_x64_2015.exe ``` -------------------------------- ### Sample services-config.json for Unity Hub Source: https://docs.unity3d.com/6000.1/Documentation/Manual/index.html/Manual/ent-unpriv-install A complete example of the services-config.json file demonstrating how to enable standard user installations and specify a shared installation directory for Unity Editors. ```json { "hubDisableElevate": true, "machineWideSecondaryInstallLocation": "C:\\UnityEditors" } ``` -------------------------------- ### Setup Channel Clients (C#) Source: https://docs.unity3d.com/6000.1/Documentation/Manual/index.html/ScriptReference/MPE.ChannelClient Initializes and configures ChannelClient instances to connect to specific channels ('custom_binary_ping_pong' and 'custom_ascii_ping_pong'). It registers message handlers for receiving data from the server and starts the clients. ```csharp static ChannelClient s_BinaryClient; static Action s_DisconnectBinaryClient; static ChannelClient s_StringClient; static Action s_DisconnectStringClient; static void HandleClientBinaryMessage(byte[] data) { Debug.Log($"Receiving pong binary data: {data} for clientId: {s_BinaryClient.clientId} with channelName: {s_BinaryClient.channelName}"); } static void HandleClientStringMessage(string data) { Debug.Log($"Receiving pong data: {data} for clientId: {s_StringClient.clientId} with channelName: {s_StringClient.channelName}"); } [MenuItem("ChannelDoc/Step 3")] static void SetupChannelClient() { const bool autoTick = true; if (s_BinaryClient == null) { s_BinaryClient = ChannelClient.GetOrCreateClient("custom_binary_ping_pong"); s_BinaryClient.Start(autoTick); s_DisconnectBinaryClient = s_BinaryClient.RegisterMessageHandler(HandleClientBinaryMessage); } Debug.Log($"[Step3] Setup client for channel custom_binary_ping_pong. ClientId: {s_BinaryClient.clientId}"); if (s_StringClient == null) { s_StringClient = ChannelClient.GetOrCreateClient("custom_ascii_ping_pong"); s_StringClient.Start(autoTick); s_DisconnectStringClient = s_StringClient.RegisterMessageHandler(HandleClientStringMessage); } Debug.Log($"[Step3] Setup client for channel custom_ascii_ping_pong. ClientId: {s_StringClient.clientId}"); } ``` -------------------------------- ### Install Unity Editor on Windows (Silent) Source: https://docs.unity3d.com/6000.1/Documentation/Manual/index.html/Manual/InstallingUnity Silently installs the Unity Editor on Windows using the setup executable with specific command-line arguments. The /S flag ensures no user interaction, and /D specifies the installation directory. ```bash UnitySetup64.exe /S /D=E:\Development\Unity ``` -------------------------------- ### Unity Android Keystores Source: https://docs.unity3d.com/6000.1/Documentation/Manual/index.html/Manual/android-getting-started Explains how to use the Android Keystore Manager to set up keystores that are required to sign an Android application. ```APIDOC APIDOC: Android Keystore Manager Functionality: - Manages cryptographic key entries for enhanced device security. - Required for signing Android applications. Usage: - Configure keystore settings within Unity's Player settings for Android. Related: - class PlayerSettingsAndroid (for keystore configuration properties) ``` -------------------------------- ### Git LFS installation success output Source: https://docs.unity3d.com/6000.1/Documentation/Manual/index.html/Manual/upm-errors This is an example of the output when `git lfs --version` is executed successfully, indicating Git LFS is installed and functional. ```shell git-lfs/2.8.0 (GitHub; darwin amd64; go 1.12.7) ``` -------------------------------- ### Unity Android Player Settings Source: https://docs.unity3d.com/6000.1/Documentation/Manual/index.html/Manual/android-getting-started Reference documentation for Android Player settings. These settings configure player-specific options for the final game built by Unity. ```APIDOC APIDOC: class PlayerSettingsAndroid Properties: Keystore Name: string Description: The name of the keystore file to use for signing the Android application. Keystore Password: string Description: The password for the keystore. Key Alias: string Description: The alias of the key within the keystore. Key Password: string Description: The password for the key. Target Architectures: enum (ARMv7, ARM64, x86, x86_64) Description: Specifies the CPU architectures to build for. Bundle Version Code: integer Description: The version code for the Android application. Incremented for each release. ``` -------------------------------- ### Create and Configure Parent Container Source: https://docs.unity3d.com/6000.1/Documentation/Manual/index.html/Manual/UIB-getting-started Sets up the root container for the UI layout, defining its flex properties and size. ```APIDOC UIBuilder: CreateVisualElement(parent: VisualElement, type: "VisualElement") - Creates a new VisualElement as a child of the specified parent. - Parameters: - parent: The parent VisualElement to attach the new element to. - type: The type of UI element to create (e.g., "VisualElement"). - Returns: The newly created VisualElement. SetInspectorProperties(element: VisualElement, properties: Object) - Sets multiple properties on a VisualElement via the Inspector panel. - Parameters: - element: The target VisualElement. - properties: An object containing key-value pairs for Inspector properties. - "Flex.Direction": "row" - "Flex.Grow": 0 - "Size.Height": "350px" - Example: SetInspectorProperties(rootElement, { "Flex.Direction": "row", "Flex.Grow": 0, "Size.Height": "350px" }) ``` -------------------------------- ### Setup OpenSSH Agent on Windows Source: https://docs.unity3d.com/6000.1/Documentation/Manual/index.html/Manual/upm-errors Configures the ssh-agent service to start automatically and then manually starts the ssh-agent process. This ensures the agent is running and ready to manage SSH keys. ```powershell # Set the ssh-agent service to start automatically and manually start it now Get-Service ssh-agent | Set-Service -StartupType Automatic # Run the ssh-agent process to start the ssh-agent service ssh-agent ``` -------------------------------- ### Start ProfilerRecorder Data Collection Source: https://docs.unity3d.com/6000.1/Documentation/Manual/index.html/ScriptReference/Unity.Profiling.ProfilerRecorder.Start Demonstrates how to start data collection for a ProfilerRecorder. This C# example shows initializing a recorder for the 'Main Thread' and starting it. It also includes cleanup logic in OnDisable. ```C# using Unity.Profiling; using UnityEngine; public class ExampleScript : MonoBehaviour { ProfilerRecorder mainThreadTimeRecorder; void OnEnable() { mainThreadTimeRecorder = new ProfilerRecorder(ProfilerCategory.Internal, "Main Thread", 15); mainThreadTimeRecorder.Start(); } void OnDisable() { mainThreadTimeRecorder.Dispose(); } } ``` -------------------------------- ### Unity MonoBehaviour Start() Example Source: https://docs.unity3d.com/6000.1/Documentation/Manual/index.html/ScriptReference/MonoBehaviour.Start Demonstrates the usage of Awake(), Start(), and Update() methods within a Unity MonoBehaviour script. Start() is shown as a Coroutine, yielding execution. ```C# using UnityEngine; using System.Collections; public class ExampleClass : MonoBehaviour { private float update; void Awake() { Debug.Log("Awake"); update = 0.0f; } IEnumerator Start() { Debug.Log("Start1"); yield return new WaitForSeconds(2.5f); Debug.Log("Start2"); } void Update() { update += Time.deltaTime; if (update > 1.0f) { update = 0.0f; Debug.Log("Update"); } } } ``` -------------------------------- ### AR Provider Plug-ins Source: https://docs.unity3d.com/6000.1/Documentation/Manual/index.html/Manual/AROverview Lists AR provider plug-ins supported by Unity, their target devices, and links to their respective documentation for integration into AR/MR projects. ```APIDOC Apple ARKit XR Plug-in: Supported devices: iOS Documentation: https://docs.unity3d.com/Packages/com.unity.xr.arkit%406.1 Apple visionOS XR Plug-in: Supported devices: visionOS Documentation: https://docs.unity3d.com/Packages/com.unity.xr.visionos%40latest Google ARCore XR Plug-in: Supported devices: Android Documentation: https://docs.unity3d.com/Packages/com.unity.xr.arcore%406.1 OpenXR Plug-in: Supported devices: Devices with an OpenXR runtime Documentation: https://docs.unity3d.com/Packages/com.unity.xr.openxr%401.15/manual/index.html Mixed Reality OpenXR Plugin (for HoloLens 2): Supported devices: HoloLens 2 Documentation: https://learn.microsoft.com/en-us/windows/mixed-reality/develop/unity/mixed-reality-openxr-plugin ``` -------------------------------- ### UXML Structure and USS Styling Concepts Source: https://docs.unity3d.com/6000.1/Documentation/Manual/index.html/Manual/UIB-getting-started Illustrates the basic structure of a UXML file and the application of USS styles for UI elements in Unity. ```APIDOC UXML Structure Example: USS Styling Concepts: - **Selectors**: Target specific elements (e.g., `.unity-visual-element`, `#my-element`, `.my-class`). - **Properties**: Define visual attributes (e.g., `flex-grow`, `align-items`, `justify-content`, `background-color`, `color`, `font-size`). - **Values**: Specify property values (e.g., `1`, `center`, `rgb(R, G, B)`, `#RRGGBB`, `12px`). - **Classes**: Apply reusable style sets to elements. - **Inline Styles**: Directly apply styles to an element within its UXML tag (e.g., ``). These can be extracted to USS classes. ``` -------------------------------- ### Unity Multiplayer Center Source: https://docs.unity3d.com/6000.1/Documentation/Manual/index.html/Manual/multiplayer Guides users to select and set up Unity multiplayer packages based on game needs, offering quickstart guidance and samples. ```APIDOC Use the Multiplayer Center: Purpose: Assists developers in choosing the right multiplayer game type, installing recommended Unity packages, and following quickstart guides for project setup. Functionality: Recommends packages, provides access to samples and tutorials. Related Topics: Unity multiplayer overview, Netcode for GameObjects, Netcode for Entities. ``` -------------------------------- ### Create and Configure Character Details Container Source: https://docs.unity3d.com/6000.1/Documentation/Manual/index.html/Manual/UIB-getting-started Establishes a container for character details, setting alignment, spacing, and background color. ```APIDOC UIBuilder: CreateVisualElement(parent: VisualElement, type: "VisualElement") - Creates a new VisualElement for character details. - Parameters: - parent: The parent VisualElement. - type: "VisualElement". - Returns: The newly created VisualElement. SetInspectorProperties(element: VisualElement, properties: Object) - Sets Inspector properties for the character details container. - Parameters: - element: The character details container element. - properties: Object with properties: - "Align.AlignItems": "flex-end" - "Align.JustifyContent": "space-between" - "Flex.Grow": 0 - "Size.Width": "276px" - "Align.AlignItems": "center" - "Align.JustifyContent": "center" - "Spacing.Padding": "8px" - "Background.Color": "#AA5939" - Example: SetInspectorProperties(characterDetailsContainer, { "Align.AlignItems": "flex-end", "Align.JustifyContent": "space-between" }); SetInspectorProperties(childElementOfDetailsContainer, { "Flex.Grow": 0, "Size.Width": "276px", "Align.AlignItems": "center", "Align.JustifyContent": "center", "Spacing.Padding": "8px", "Background.Color": "#AA5939" }) ``` -------------------------------- ### Start Channel Service (C#) Source: https://docs.unity3d.com/6000.1/Documentation/Manual/index.html/ScriptReference/MPE.ChannelClient Demonstrates how to start the Unity ChannelService, which acts as a WebSocket server. It checks if the service is already running and logs its address and port. Requires UnityEditor namespace. ```csharp using System; using System.Text; using UnityEditor.MPE; using UnityEditor; using UnityEngine; public static class ChannelCommunicationDocExample { [MenuItem("ChannelDoc/Step 1")] static void StartChannelService() { if (!ChannelService.IsRunning()) { ChannelService.Start(); } Debug.Log($"[Step1] ChannelService Running: {ChannelService.GetAddress()}:{ChannelService.GetPort()}"); } static int s_BinaryChannelId; static int s_StringChannelId; static Action s_DisconnectBinaryChannel; static Action s_DisconnectStringChannel; static void HandleChannelBinaryMessage(int connectionId, byte[] data) { var msg = ""; for (var i = 0; i < Math.Min(10, data.Length); ++i) { msg += data[i].ToString(); } Debug.Log($"Channel Handling binary from connection {connectionId} - {data.Length} bytes - {msg}"); // Client has sent a message (this is a ping) // Lets send back the same message (as a pong) ChannelService.Send(connectionId, data); } static void HandleChannelStringMessage(int connectionId, byte[] data) { // A new message is received. // Since our clients expects string data. Encode the data and send it back as a string: var msgStr = Encoding.UTF8.GetString(data); Debug.Log($"Channel Handling string from connection {connectionId} - {msgStr}"); // Client has sent a message (this is a ping) // Lets send back the same message (as a pong) ChannelService.Send(connectionId, msgStr); } [MenuItem("ChannelDoc/Step 2")] static void SetupChannelService() { if (s_DisconnectBinaryChannel == null) { s_DisconnectBinaryChannel = ChannelService.GetOrCreateChannel("custom_binary_ping_pong", HandleChannelBinaryMessage); s_BinaryChannelId = ChannelService.ChannelNameToId("custom_binary_ping_pong"); } Debug.Log($"[Step2] Setup channel_custom_binary id: {s_BinaryChannelId}"); if (s_DisconnectStringChannel == null) { s_DisconnectStringChannel = ChannelService.GetOrCreateChannel("custom_ascii_ping_pong", HandleChannelStringMessage); s_StringChannelId = ChannelService.ChannelNameToId("custom_ascii_ping_pong"); } Debug.Log($"[Step2] Setup channel_custom_ascii id: {s_StringChannelId}"); } static ChannelClient s_BinaryClient; static Action s_DisconnectBinaryClient; static ChannelClient s_StringClient; static Action s_DisconnectStringClient; static void HandleClientBinaryMessage(byte[] data) { Debug.Log($"Receiving pong binary data: {data} for clientId: {s_BinaryClient.clientId} with channelName: {s_BinaryClient.channelName}"); } static void HandleClientStringMessage(string data) { Debug.Log($"Receiving pong data: {data} for clientId: {s_StringClient.clientId} with channelName: {s_StringClient.channelName}"); } [MenuItem("ChannelDoc/Step 3")] static void SetupChannelClient() { const bool autoTick = true; if (s_BinaryClient == null) { s_BinaryClient = ChannelClient.GetOrCreateClient("custom_binary_ping_pong"); s_BinaryClient.Start(autoTick); s_DisconnectBinaryClient = s_BinaryClient.RegisterMessageHandler(HandleClientBinaryMessage); } Debug.Log($"[Step3] Setup client for channel custom_binary_ping_pong. ClientId: {s_BinaryClient.clientId}"); if (s_StringClient == null) { s_StringClient = ChannelClient.GetOrCreateClient("custom_ascii_ping_pong"); s_StringClient.Start(autoTick); s_DisconnectStringClient = s_StringClient.RegisterMessageHandler(HandleClientStringMessage); } Debug.Log($"[Step3] Setup client for channel custom_ascii_ping_pong. ClientId: {s_StringClient.clientId}"); } [MenuItem("ChannelDoc/Step 4")] static void ClientSendMessageToServer() { Debug.Log("[Step 4]: Clients are sending data!"); s_BinaryClient.Send(new byte[] { 0, 1, 2, 3, 4, 5, 6, 7 }); s_StringClient.Send("Hello world!"); } [MenuItem("ChannelDoc/Step 5")] static void CloseClients() { // Placeholder for closing clients, actual implementation would involve calling Dispose or similar Debug.Log("[Step 5]: Closing clients (implementation details omitted)."); // Example: s_BinaryClient?.Dispose(); // Example: s_StringClient?.Dispose(); } } ``` -------------------------------- ### Create and Configure Character List Container Source: https://docs.unity3d.com/6000.1/Documentation/Manual/index.html/Manual/UIB-getting-started Adds a ListView to the layout, names it, sets its dimensions, and applies background and border styling. ```APIDOC UIBuilder: CreateVisualElement(parent: VisualElement, type: "ListView") - Creates a new ListView as a child of the specified parent. - Parameters: - parent: The parent VisualElement. - type: "ListView". - Returns: The newly created ListView. SetInspectorProperties(element: VisualElement, properties: Object) - Sets Inspector properties for the ListView. - Parameters: - element: The ListView element. - properties: Object with properties: - "Name": "CharacterList" - "Size.Width": "230px" - "Spacing.Margin.Right": "6px" - "Background.Color": "#6E3925" - "Border.Color": "#311A11" - "Border.Width": "4px" - "Border.Radius": "15px" - Example: SetInspectorProperties(characterListElement, { "Name": "CharacterList", "Size.Width": "230px", "Spacing.Margin.Right": "6px", "Background.Color": "#6E3925", "Border.Color": "#311A11", "Border.Width": "4px", "Border.Radius": "15px" }) ``` -------------------------------- ### Custom Workflow: Play From First Scene Source: https://docs.unity3d.com/6000.1/Documentation/Manual/index.html/ScriptReference/EditorApplication An example demonstrating how to create a custom Unity Editor workflow to start the game from the first scene in build settings and restore the authoring state upon returning to edit mode. This script uses `EditorApplication` to manage play mode state changes and `EditorSceneManager` to handle scene loading and setup. ```C# using UnityEditor; using UnityEditor.SceneManagement; using UnityEngine.SceneManagement; [InitializeOnLoad] public static class PlayFromFirstScene { static SceneSetup[] s_PreviousAuthoringSceneSetup; [MenuItem("Examples/Play From First Scene", isValidateFunction: true)] static bool CanExecute() { return SceneManager.sceneCountInBuildSettings > 0 && !EditorApplication.isPlayingOrWillChangePlaymode; } [MenuItem("Examples/Play From First Scene")] static void Execute() { if (!EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo()) return; s_PreviousAuthoringSceneSetup = EditorSceneManager.GetSceneManagerSetup(); EditorSceneManager.OpenScene(SceneUtility.GetScenePathByBuildIndex(0), OpenSceneMode.Single); EditorApplication.EnterPlaymode(); } static PlayFromFirstScene() { EditorApplication.playModeStateChanged += OnPlaymodeStateChanged; } static void OnPlaymodeStateChanged(PlayModeStateChange state) { if (state == PlayModeStateChange.EnteredEditMode && s_PreviousAuthoringSceneSetup != null) { EditorSceneManager.RestoreSceneManagerSetup(s_PreviousAuthoringSceneSetup); s_PreviousAuthoringSceneSetup = null; } } } ``` -------------------------------- ### Manual Scene Setup Steps Source: https://docs.unity3d.com/6000.1/Documentation/Manual/index.html/Manual/AROverview Steps to manually add AR Session and XR Origin GameObjects to a Unity scene. Ensure only one active XR Origin is present in the scene. ```APIDOC Manual Scene Setup: 1. Right-click in the Hierarchy window. 2. Navigate to GameObject > XR. 3. Select the relevant component (e.g., XR Origin). Note: A scene must contain only one active XR Origin GameObject. ``` -------------------------------- ### Start Recording with Microphone Source: https://docs.unity3d.com/6000.1/Documentation/Manual/index.html/ScriptReference/Microphone.Start This C# example demonstrates how to start recording audio using the default microphone and immediately play it back through an AudioSource component. It initializes an AudioSource and assigns the recorded audio clip to it. ```C# using UnityEngine; public class Example : MonoBehaviour { // Start recording with built-in Microphone and play the recorded audio right away void Start() { AudioSource audioSource = GetComponent(); audioSource.clip = Microphone.Start("Built-in Microphone", true, 10, 44100); audioSource.Play(); } } ``` -------------------------------- ### Common UPM Git Installation Errors Source: https://docs.unity3d.com/6000.1/Documentation/Manual/index.html/Manual/upm-ui-giturl Lists potential error messages encountered during UPM package installation from Git URLs and links to troubleshooting guides. These errors relate to Git client availability, repository access, and authentication. ```APIDOC Error Messages: - No 'Git' executable was found - Git-lfs: command not found - Repository not found - Couldn’t read Username: terminal prompts disabled ``` -------------------------------- ### Configure Character Name Label Source: https://docs.unity3d.com/6000.1/Documentation/Manual/index.html/Manual/UIB-getting-started Sets up the label for displaying the character's name. This includes styling the font to be bold and setting the font size. ```APIDOC Label: Name: CharacterName Type: UI Label Properties: Text: Font Style: B (Bold) Size: 18 pixels ``` -------------------------------- ### AR Session GameObject Setup Source: https://docs.unity3d.com/6000.1/Documentation/Manual/index.html/Manual/AROverview The AR Session GameObject manages the lifecycle and input for AR experiences. It requires the AR Session and AR Input Manager components. ```APIDOC AR Session GameObject: - Manages AR experience lifecycle and input. - Components: - AR Session component (com.unity.xr.arfoundation) - AR Input Manager component (com.unity.xr.arfoundation) ``` -------------------------------- ### Configure Character Class Label Source: https://docs.unity3d.com/6000.1/Documentation/Manual/index.html/Manual/UIB-getting-started Sets up the label for displaying the character's class. This includes styling the font to be bold and setting the font size. ```APIDOC Label: Name: CharacterClass Type: UI Label Properties: Text: Font Style: B (Bold) Size: 18 pixels ``` -------------------------------- ### Mesh.Optimize Method Example Source: https://docs.unity3d.com/6000.1/Documentation/Manual/index.html/ScriptReference/Mesh.Optimize Example usage of the Mesh.Optimize() method in Unity to improve rendering performance by reordering mesh data. This script gets the Mesh component from the GameObject and calls Optimize() in the Start method. ```C# using UnityEngine; public class Example : MonoBehaviour { void Start() { Mesh mesh = gameObject.GetComponent().mesh; mesh.Optimize(); } } ``` -------------------------------- ### Get Script Paths Example (C#) Source: https://docs.unity3d.com/6000.1/Documentation/Manual/index.html/ScriptReference/Search.SearchExpression Demonstrates how to create a search context and open the search window to find script paths. This method utilizes Unity's SearchService API. ```csharp using UnityEngine; public class SearchExample : MonoBehaviour { [MenuItem("Examples/ExpressionEvaluator/Get Script Paths")] static void GetScriptPaths() { var ctx = SearchService.CreateContext("formatitems{t:script search}"); SearchService.ShowWindow(ctx); } } ``` -------------------------------- ### Run Unity Accelerator (Basic) Source: https://docs.unity3d.com/6000.1/Documentation/Manual/index.html/Manual/accelerator-install-docker Starts the Unity Accelerator container, mapping essential ports and mounting a local directory for agent data. ```bash $ docker run -p 80:80 -p 443:443 -p 10080:10080 -v "${PWD}/agent:/agent" unitytechnologies/accelerator:latest ``` -------------------------------- ### Initialize Script with Debug Log Source: https://docs.unity3d.com/6000.1/Documentation/Manual/index.html/Manual/class-MonoBehaviour This C# code snippet demonstrates how to use the Start function in Unity to log a message to the console upon initialization. The Start function is called once when the script instance is enabled, making it ideal for setup tasks. ```csharp // Use this for initialization void Start () { Debug.Log("Hello world!"); } ``` -------------------------------- ### Unity EventService Usage Example Source: https://docs.unity3d.com/6000.1/Documentation/Manual/index.html/ScriptReference/MPE.EventService Demonstrates how to use the EventService to start the ChannelService, register event handlers, emit messages, and send requests. Includes setup, message sending, request/response, and cleanup steps. ```C# using UnityEditor; using UnityEngine; using UnityEditor.MPE; using System; public static class EventServiceDocExample { static Action s_CustomLogEventDisconnect; static Action s_PingPongEventDisconnect; [MenuItem("EventServiceDoc/Step 0")] static void StartChannelService() { if (!ChannelService.IsRunning()) { ChannelService.Start(); } Debug.Log($"[Step 0] ChannelService Running: {ChannelService.GetAddress()}:{ChannelService.GetPort()}"); } [MenuItem("EventServiceDoc/Step 1")] static void SetupEventServiceHandlers() { Debug.Log("[Step 1] Setup handlers"); s_CustomLogEventDisconnect = EventService.RegisterEventHandler("custom_log", (eventType, args) => { Debug.Log($"Log a {eventType} {args[0]}"); }); s_PingPongEventDisconnect = EventService.RegisterEventHandler("pingpong", (eventType, args) => { Debug.Log($"Receive a {eventType} {args[0]}"); return "pong!"; }); } [MenuItem("EventServiceDoc/Step 2")] static void EmitMessage() { Debug.Log("[Step 2] Emitting a custom log"); EventService.Emit("custom_log", "Hello world!", -1, EventDataSerialization.JsonUtility); } [MenuItem("EventServiceDoc/Step 3")] static void SendRequest() { Debug.Log("[Step 3] Sending a request"); EventService.Request("pingpong", (err, data) => { Debug.Log($"Request fulfilled: {data[0]}"); }, "ping", -1, EventDataSerialization.JsonUtility); } [MenuItem("EventServiceDoc/Step 4")] static void CloseHandlers() { Debug.Log("[Step 4] Closing all Event handlers"); s_CustomLogEventDisconnect(); s_PingPongEventDisconnect(); } } /* When you execute the five menu items one after the other, Unity prints the following messages to the Console window: [Step 0] ChannelService Running: 127.0.0.1:65000 [Step 1] Setup handlers [Step 2] Emitting a custom log Log a custom_log Hello world! [Step 3] Sending a request Receive a pingpong ping Request fulfilled: pong! [Step 4] Closing all Event handlers */ ``` -------------------------------- ### Unity: Lift Rigidbody via Collider Source: https://docs.unity3d.com/6000.1/Documentation/Manual/index.html/ScriptReference/Collider-attachedRigidbody This C# example demonstrates how to get the Rigidbody component attached to a Collider and apply an upward force to it. It's typically used within a MonoBehaviour's Start or Update method. ```csharp using UnityEngine; public class Example : MonoBehaviour { void Start() { // Lift the rigidbody attached to the collider. GetComponent().attachedRigidbody.AddForce(0, 1, 0); } } ``` -------------------------------- ### Unity QNX Player Startup Time Logging Example Source: https://docs.unity3d.com/6000.1/Documentation/Manual/index.html/Manual/qnx-optional-features Example output logs demonstrating the startup time logging for the Unity QNX Player, showing durations for various initialization stages. ```log [TIMING::STARTUP] Initial probing done: Real: 19 ms | User: 11 ms [TIMING::STARTUP] SDL Initialized: Real: 64 ms | User: 54 ms [TIMING::STARTUP] Scripting runtime loaded: Real: 97 ms | User: 86 ms [TIMING::STARTUP] Plugins loaded: Real: 97 ms | User: 87 ms [TIMING::STARTUP] Engine initialized (nogfx): Real: 104 ms | User: 94 ms [TIMING::STARTUP] Player Prefs loaded: Real: 104 ms | User: 94 ms [TIMING::STARTUP] Screen initialized: Real: 139 ms | User: 112 ms [TIMING::STARTUP] Engine initialized (gfx): Real: 187 ms | User: 161 ms [TIMING::STARTUP] Gfx initialized: Real: 190 ms | User: 163 ms [TIMING::STARTUP] Input initialized: Real: 190 ms | User: 163 ms [TIMING::STARTUP] SPLASH - Begin: Real: 190 ms | User: 164 ms [TIMING::STARTUP] SPLASH - Primary scene assets loaded (async): Real: 2197 ms | User: 1670 ms [TIMING::STARTUP] SPLASH - All engine initial states established: Real: 2197 ms | User: 1670 ms ``` ```log [TIMING::STARTUP] HELLO!!: Real: 2198 ms | User: 1671 ms ``` ```log [TIMING::STARTUP] Frame 1 rendered: Real: 2209 ms | User: 1687 ms [TIMING::STARTUP] Frame 2 rendered: Real: 2210 ms | User: 1692 ms ``` -------------------------------- ### Example Startup Log Entries Source: https://docs.unity3d.com/6000.1/Documentation/Manual/index.html/Manual/embedded-linux-optional-features Provides sample output lines from the Player.log file, demonstrating various startup events and their corresponding real and user time durations in milliseconds. ```text [TIMING::STARTUP] Initial probing done: Real: 19 ms | User: 11 ms [TIMING::STARTUP] SDL Initialized: Real: 64 ms | User: 54 ms [TIMING::STARTUP] Scripting runtime loaded: Real: 97 ms | User: 86 ms [TIMING::STARTUP] Plugins loaded: Real: 97 ms | User: 87 ms [TIMING::STARTUP] Engine initialized (nogfx): Real: 104 ms | User: 94 ms [TIMING::STARTUP] Player Prefs loaded: Real: 104 ms | User: 94 ms [TIMING::STARTUP] Screen initialized: Real: 139 ms | User: 112 ms [TIMING::STARTUP] Engine initialized (gfx): Real: 187 ms | User: 161 ms [TIMING::STARTUP] Gfx initialized: Real: 190 ms | User: 163 ms [TIMING::STARTUP] Input initialized: Real: 190 ms | User: 163 ms [TIMING::STARTUP] SPLASH - Begin: Real: 190 ms | User: 164 ms [TIMING::STARTUP] SPLASH - Primary scene assets loaded (async): Real: 2197 ms | User: 1670 ms [TIMING::STARTUP] SPLASH - All engine initial states established: Real: 2197 ms | User: 1670 ms ``` -------------------------------- ### Full Assembly Definition JSON Example (GUIDs) Source: https://docs.unity3d.com/6000.1/Documentation/Manual/index.html/Manual/assembly-definition-file-format A complete example of an Assembly Definition JSON file using GUIDs for references and specifying platform exclusions. ```JSON { "name": "BeeAssembly", "references": [ "GUID:17b36165d09634a48bf5a0e4bb27f4bd", "GUID:b470eee7144904e59a1064b70fa1b086", "GUID:2bafac87e7f4b9b418d9448d219b01ab", "GUID:27619889b8ba8c24980f49ee34dbb44a", "GUID:0acc523941302664db1f4e527237feb3" ], "includePlatforms": [], "excludePlatforms": [ "iOS", "macOSStandalone", "tvOS" ], "allowUnsafeCode": false, "overrideReferences": true, "precompiledReferences": [ "Newtonsoft.Json.dll", "nunit.framework.dll" ], "autoReferenced": false, "defineConstraints": [ "UNITY_2019", "UNITY_INCLUDE_TESTS" ], "versionDefines": [ { "name": "com.unity.ide.vscode", "expression": "[1.7,2.4.1]", "define": "MY_SYMBOL" }, { "name": "com.unity.test-framework", "expression": "[2.7.2-preview.8]", "define": "TESTS" } ], "noEngineReferences": false } ``` -------------------------------- ### Configure Character Portrait Background Source: https://docs.unity3d.com/6000.1/Documentation/Manual/index.html/Manual/UIB-getting-started Sets up the visual appearance of the character portrait background element. This involves defining size, padding, background color, border color, and border radius. ```APIDOC VisualElement: Type: UI Element Properties: Size: Width: 120 pixels Height: 120 pixels Spacing: Padding: 4 pixels Background: Color: #FF8554 Border: Color: #311A11 Width: 2 pixels Radius: 13 pixels ``` -------------------------------- ### MonoBehaviour.didStart C# Example Source: https://docs.unity3d.com/6000.1/Documentation/Manual/index.html/ScriptReference/MonoBehaviour-didStart Illustrates the `didStart` property of Unity's MonoBehaviour. The example shows that `didStart` returns `false` when checked in `Awake()` and `true` when checked in `Start()`, indicating if the `Start()` method has been called. ```C# using UnityEngine; public class NewBehaviourScript : MonoBehaviour { void Awake() { // Awake gets called before Start, therefore will print 'false'. Debug.Log(this.didStart); } void Start() { // Code is within Start, therefore will print 'true', as Start was called. Debug.Log(this.didStart); } } ``` -------------------------------- ### Unity Resources System Overview Source: https://docs.unity3d.com/6000.1/Documentation/Manual/index.html/Manual/LoadingResourcesatRuntime Provides an overview of Unity's Resources system, which allows developers to load assets from 'Resources' folders at runtime. It details suitable use cases like rapid prototyping and small projects, while also highlighting performance impacts and recommending alternatives like AssetBundles and Addressables for larger or more complex asset management needs. ```APIDOC Resources Class: Purpose: Allows finding and accessing objects in 'Resources' folders. Usage: Assets placed in a 'Resources' folder are available to load when needed, independent of scenes. Considerations: - Performance Impact: Large asset sets in Resources folders can slow down application startup, build times, and increase memory usage. - Asset Management: Makes memory management difficult and hinders incremental content upgrades. - Alternatives: AssetBundles and the Addressables package are recommended for better performance and asset management, especially for complex projects. Suitable Use Cases: - Rapid prototyping. - Small projects where content is needed throughout the project's lifetime, is not memory-intensive, and doesn't require patching or platform-specific variations. - Minimal bootstrapping (e.g., MonoBehaviour singletons, ScriptableObject instances with configuration data). ``` -------------------------------- ### Start Coroutine Example Source: https://docs.unity3d.com/6000.1/Documentation/Manual/index.html/Manual/Coroutines Demonstrates how to initiate a coroutine when a specific input key is pressed within the Update method. ```C# void Update() { if (Input.GetKeyDown("f")) { StartCoroutine(Fade()); } } ``` -------------------------------- ### Valid Git URL Formats for UPM Source: https://docs.unity3d.com/6000.1/Documentation/Manual/index.html/Manual/upm-ui-giturl Provides examples of correctly formatted Git URLs that can be used to install UPM packages. This includes basic repository URLs and URLs specifying a subfolder within the repository. ```APIDOC Git URL Examples: - Basic: https://github.example.com/myuser/myrepo.git - With subfolder: https://github.example.com/myuser/myrepo.git?path=/subfolder ``` -------------------------------- ### Get BlendShape Weight Example Source: https://docs.unity3d.com/6000.1/Documentation/Manual/index.html/ScriptReference/SkinnedMeshRenderer.GetBlendShapeWeight Example demonstrating how to retrieve the weight of a BlendShape using its index. ```C# public class BlendShapeExample : MonoBehaviour { public SkinnedMeshRenderer skinnedMeshRenderer; public int blendShapeIndex = 0; void Start() { if (skinnedMeshRenderer == null) { skinnedMeshRenderer = GetComponent(); } if (skinnedMeshRenderer != null && blendShapeIndex < skinnedMeshRenderer.sharedMesh.blendShapeCount) { float weight = skinnedMeshRenderer.GetBlendShapeWeight(blendShapeIndex); Debug.Log("BlendShape weight at index " + blendShapeIndex + ": " + weight); } else { Debug.LogError("SkinnedMeshRenderer not found or blend shape index is out of bounds."); } } } ``` -------------------------------- ### Unity Command-line Arguments Source: https://docs.unity3d.com/6000.1/Documentation/Manual/index.html/Manual/building-and-publishing Examples of using command-line arguments to run the Unity Editor and standalone Player applications. ```APIDOC Unity Editor Command-line Arguments: // Example: Open a project and build for a specific platform Unity.exe -projectPath "/path/to/your/project" -buildWindowsPlayer "/path/to/build/MyGame.exe" -quit // Example: Execute a specific editor method Unity.exe -projectPath "/path/to/your/project" -executeMethod MyEditorScript.PerformBuild -quit // Common Arguments: // -projectPath : Specifies the path to the Unity project. // -buildWindowsPlayer : Builds a Windows standalone player. // -buildOSXPlayer : Builds a macOS standalone player. // -executeMethod : Executes a static method in an editor script. // -quit: Exits the Unity Editor after completing the command. // -batchmode: Runs Unity in batch mode (no GUI). // -nographics: Runs Unity without initializing the graphics device (useful for server builds). // Standalone Player Command-line Arguments: // -logFile : Specifies a file to write log output to. // -screen-width : Sets the screen width. // -screen-height : Sets the screen height. // -popupwindow: Runs the player in a window without a border. // Note: Refer to Unity documentation for a complete list of command-line arguments. ``` -------------------------------- ### Unity Custom Build Processor Example Source: https://docs.unity3d.com/6000.1/Documentation/Manual/index.html/ScriptReference/Android.IPostGenerateGradleAndroidProject.OnPostGenerateGradleAndroidProject Example C# code demonstrating how to implement the IPostGenerateGradleAndroidProject interface to execute custom logic after the Android Gradle project is generated and before the build starts. It logs the path to the Unity library Gradle project. ```C# using UnityEditor; using UnityEditor.Android; using UnityEngine; class MyCustomBuildProcessor : IPostGenerateGradleAndroidProject { public int callbackOrder { get { return 0; } } public void OnPostGenerateGradleAndroidProject(string path) { Debug.Log("MyCustomBuildProcessor.OnPostGenerateGradleAndroidProject at path " + path); } } ``` -------------------------------- ### Unity Awake Lifecycle Example 1 Source: https://docs.unity3d.com/6000.1/Documentation/Manual/index.html/ScriptReference/MonoBehaviour.Awake Illustrates Example1 script's Awake and Start methods. Awake is called first, followed by Start. This example shows how Awake is called even if the GameObject is initially inactive. ```csharp using UnityEngine; // Make sure that Cube1 is assigned this script and is inactive at the start of the game. public class Example1 : MonoBehaviour { void Awake() { // Prints first Debug.Log("Example1.Awake() was called"); } void Start() { // Prints second Debug.Log("Example1.Start() was called"); } void Update() { if (Input.GetKeyDown("b")) { // Prints Last if "b" is pressed Debug.Log("b key was pressed"); } } } ``` -------------------------------- ### Unity Accelerator Command Line Installation Source: https://docs.unity3d.com/6000.1/Documentation/Manual/index.html/Manual/accelerator-install-installer Instructions for running the Unity Accelerator installer from the command line for automated or unattended installations. Includes common arguments for specifying storage directories and installation modes. ```APIDOC Installer Arguments: --help: Displays available command line options. --storagedir : Sets the directory for the Accelerator to store files and configurations. --mode unattended: Use for automated installations that don’t need to query anything. This uses default values, or values from other option flags provided. macOS Specific: Mount the disk image (.dmg) and run the binary located in the installer app’s directory at Contents/macOS/installbuilder.sh. Reference: For a full list of command line options, refer to the [Command line arguments reference](EditorCommandLineArguments.html#accelerator). ``` -------------------------------- ### Unity Editor Installation and Project Creation Source: https://docs.unity3d.com/6000.1/Documentation/Manual/index.html/Manual/create-first-project Steps to install the Unity Editor and create a new project using the Unity Hub. This process involves installing the Unity Hub, creating a Unity account, installing the Unity Editor (version 6.1 or later), and then creating a new project from a template. ```APIDOC Unity Hub Actions: 1. Install Unity Hub - Manages Unity installations and projects. 2. Create Unity Account - Provides access to free assets, collaboration tools, and services. 3. Install Unity Editor - Requires version 6.1 or later. - Download and install via Unity Hub. 4. Create New Project - In Unity Hub, select 'New project'. - Choose template: 'Get Started With Unity' (includes sample game and tutorials). - Select 'Download template'. - Name your project and choose a save location. - Select 'Create project'. - Unity Editor opens and loads the project. - Follow in-Editor tutorials to learn Unity basics. ``` -------------------------------- ### Get Component Count Example Source: https://docs.unity3d.com/6000.1/Documentation/Manual/index.html/ScriptReference/GameObject.GetComponentCount Example demonstrating how to use `GetComponentCount` to iterate through components on a GameObject and find a specific component like Rigidbody. ```C# using UnityEngine; public class IterateComponents : MonoBehaviour { int m_SavedComponentIndex = -1; void Start() { //Iterate through components on the GameObject for (int i = 0; i < gameObject.GetComponentCount(); i++) { var currComponent = gameObject.GetComponentAtIndex(i); //Check if it is a Rigidbody component if (currComponent.GetType() == typeof(Rigidbody) ) { m_SavedComponentIndex = i; } } Debug.Log(m_SavedComponentIndex != -1 ? $"Found component at index: {m_SavedComponentIndex}" : "Could not find component"); } } ``` -------------------------------- ### Create Unity Hub services-config.json file Source: https://docs.unity3d.com/6000.1/Documentation/Manual/index.html/Manual/ent-unpriv-install Ensures the necessary directory and configuration file exist for Unity Hub settings. The file should contain at least an empty JSON object if no specific configurations are added initially. ```json { } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.