### Quick Start Example Source: https://github.com/besty0728/unity-skills/blob/main/SkillsForUnity/unity-skills~/skills/netcode/SKILL.md A comprehensive example demonstrating the setup and lifecycle of a Unity Netcode session using unity-skills. This includes inspecting setup, creating NetworkManager, configuring NetworkConfig, setting up transport, player prefab, generating a NetworkBehaviour script, and driving the session through PlayMode. ```python import unity_skills as u # 1. Inspect current state u.call_skill("netcode_check_setup") # 2. Create NetworkManager + UnityTransport u.call_skill("netcode_create_manager", name="NetworkManager") # 3. Configure the NetworkConfig u.call_skill("netcode_configure_manager", tickRate=30, connectionApproval=False, enableSceneManagement=True, networkTopology="ClientServer") # 4. Transport u.call_skill("netcode_set_transport_address", address="127.0.0.1", port=7777, serverListenAddress="0.0.0.0") # 5. Player prefab setup # NOTE: add_network_object on a prefab path depends on GameObjectFinder support. # Safer route: instantiate the prefab in the scene first, then attach. u.call_skill("netcode_add_network_object", path="Assets/Prefabs/Player.prefab") u.call_skill("netcode_create_prefabs_list", path="Assets/NetworkPrefabs.asset") u.call_skill("netcode_add_to_prefabs_list", listPath="Assets/NetworkPrefabs.asset", prefabPath="Assets/Prefabs/Player.prefab") u.call_skill("netcode_set_player_prefab", prefabPath="Assets/Prefabs/Player.asset") # 6. Generate a NetworkBehaviour template u.call_skill("netcode_add_network_behaviour_script", className="PlayerController", path="Assets/Scripts/PlayerController.cs", includeRpc=True, includeNetworkVariable=True) # 7. Drive the session in PlayMode u.call_skill("editor_play") # enter PlayMode u.call_skill("netcode_start_host") u.call_skill("netcode_get_status") u.call_skill("netcode_shutdown") u.call_skill("editor_stop") ``` -------------------------------- ### Complete Animation Setup Example Source: https://github.com/besty0728/unity-skills/blob/main/SkillsForUnity/unity-skills~/skills/animator/SKILL.md This example demonstrates a full animation setup process, including creating a controller, adding parameters, assigning the controller to a character, and controlling animation parameters and states at runtime. Ensure the controller is created before adding parameters and parameters are set before playing states. ```python import unity_skills # 1. Create controller unity_skills.call_skill("animator_create_controller", name="PlayerController", folder="Assets/Animations" ) # 2. Add parameters unity_skills.call_skill("animator_add_parameter", controllerPath="Assets/Animations/PlayerController.controller", paramName="Speed", paramType="float", defaultFloat=0 ) unity_skills.call_skill("animator_add_parameter", controllerPath="Assets/Animations/PlayerController.controller", paramName="IsGrounded", paramType="bool", defaultBool=True ) unity_skills.call_skill("animator_add_parameter", controllerPath="Assets/Animations/PlayerController.controller", paramName="Jump", paramType="trigger" ) # 3. Assign to character unity_skills.call_skill("animator_assign_controller", name="Player", controllerPath="Assets/Animations/PlayerController.controller" ) # 4. Control at runtime unity_skills.call_skill("animator_set_parameter", name="Player", paramName="Speed", paramType="float", floatValue=5.0 ) # Trigger jump unity_skills.call_skill("animator_set_parameter", name="Player", paramName="Jump", paramType="trigger" ) # Play specific state unity_skills.call_skill("animator_play", name="Player", stateName="Idle") ``` -------------------------------- ### Efficient Physics Setup Example Source: https://github.com/besty0728/unity-skills/blob/main/SkillsForUnity/unity-skills~/skills/component/SKILL.md Compares inefficient individual API calls with efficient batch calls for adding Rigidbody components and setting their mass. Use batch operations for better performance. ```python import unity_skills # BAD: 6 API calls unity_skills.call_skill("component_add", name="Box1", componentType="Rigidbody") unity_skills.call_skill("component_add", name="Box2", componentType="Rigidbody") unity_skills.call_skill("component_add", name="Box3", componentType="Rigidbody") unity_skills.call_skill("component_set_property", name="Box1", componentType="Rigidbody", propertyName="mass", value=2.0) unity_skills.call_skill("component_set_property", name="Box2", componentType="Rigidbody", propertyName="mass", value=2.0) unity_skills.call_skill("component_set_property", name="Box3", componentType="Rigidbody", propertyName="mass", value=2.0) # GOOD: 2 API calls unity_skills.call_skill("component_add_batch", items=[ {"name": "Box1", "componentType": "Rigidbody"}, {"name": "Box2", "componentType": "Rigidbody"}, {"name": "Box3", "componentType": "Rigidbody"} ]) unity_skills.call_skill("component_set_property_batch", items=[ {"name": "Box1", "componentType": "Rigidbody", "propertyName": "mass", "value": 2.0}, {"name": "Box2", "componentType": "Rigidbody", "propertyName": "mass", "value": 2.0}, {"name": "Box3", "componentType": "Rigidbody", "propertyName": "mass", "value": 2.0} ]) ``` -------------------------------- ### Minimal XR Rig and Interaction Setup Source: https://github.com/besty0728/unity-skills/blob/main/SkillsForUnity/unity-skills~/skills/xr/SKILL.md Sets up a minimal XR rig with a camera offset, event system, a ray interactor, a grab interactable with throwing enabled, and haptic feedback configuration. This is a good starting point for basic interaction. ```python import unity_skills as u u.call_skill("xr_setup_rig", name="XR Origin", cameraYOffset=1.36) u.call_skill("xr_setup_event_system") u.call_skill("xr_add_ray_interactor", name="Right Controller", maxDistance=30, lineType="StraightLine") u.call_skill("xr_add_grab_interactable", name="Tool", movementType="VelocityTracking", throwOnDetach=True) u.call_skill("xr_configure_haptics", name="Right Controller", selectIntensity=0.7, selectDuration=0.15) ``` -------------------------------- ### XR Rig Setup Source: https://github.com/besty0728/unity-skills/blob/main/SkillsForUnity/unity-skills~/skills/xr/API_REFERENCE.md Sets up the XR rig, including checking the setup, adding the rig, event system, and interactors for controllers. Ensure the checklist items are met for a successful setup. ```python import unity_skills as u result = u.call_skill("xr_check_setup", verbose=True) u.call_skill("xr_setup_rig", name="XR Origin", cameraYOffset=1.36) u.call_skill("xr_setup_event_system") u.call_skill("xr_add_ray_interactor", name="Right Controller", maxDistance=30) u.call_skill("xr_add_direct_interactor", name="Left Controller", radius=0.1) ``` -------------------------------- ### Minimal Example: Create and Configure GameObjects Source: https://github.com/besty0728/unity-skills/blob/main/SkillsForUnity/unity-skills~/skills/gameobject/SKILL.md This example demonstrates creating multiple game objects, setting their transforms, and assigning tags in a concise manner using batch operations. It's more efficient than individual API calls. ```python import unity_skills # GOOD: 3 API calls instead of 6 unity_skills.call_skill("gameobject_create_batch", items=[ {"name": "Floor", "primitiveType": "Plane"}, {"name": "Wall1", "primitiveType": "Cube"}, {"name": "Wall2", "primitiveType": "Cube"} ]) unity_skills.call_skill("gameobject_set_transform_batch", items=[ {"name": "Wall1", "posX": -5, "scaleY": 3}, {"name": "Wall2", "posX": 5, "scaleY": 3} ]) unity_skills.call_skill("gameobject_set_tag_batch", items=[ {"name": "Wall1", "tag": "Wall"}, {"name": "Wall2", "tag": "Wall"} ]) ``` -------------------------------- ### Ease Examples Source: https://github.com/besty0728/unity-skills/blob/main/SkillsForUnity/unity-skills~/skills/dotween-design/EASE.md Provides code examples for using specific eases like OutBack, OutElastic, and the Flash family. ```APIDOC ## Ease Examples ### OutBack Overshoot Demonstrates how to control the overshoot effect for `OutBack` ease. ```csharp // Default overshoot (1.70158) transform.DOScale(Vector3.one, 0.3f).SetEase(Ease.OutBack); // Milder overshoot transform.DOScale(Vector3.one, 0.3f).SetEase(Ease.OutBack, overshoot: 0.8f); // Dramatic overshoot transform.DOScale(Vector3.one, 0.3f).SetEase(Ease.OutBack, overshoot: 2.5f); ``` ### OutElastic Amplitude & Period Shows how to adjust the amplitude and period for `OutElastic` ease to create different spring effects. ```csharp // Default amplitude (1.70158), period (0.3) - slight bounce transform.DOMoveY(5f, 1f).SetEase(Ease.OutElastic); // Stiff spring (fast oscillation, small amplitude) transform.DOMoveY(5f, 1f).SetEase(Ease.OutElastic, amplitude: 0.5f, period: 0.1f); // Floppy spring (slow oscillation, big amplitude) transform.DOMoveY(5f, 1f).SetEase(Ease.OutElastic, amplitude: 2f, period: 0.8f); ``` ### Flash Family Example Illustrates the usage of the `Flash` family of eases, which require specific parameters for the number of flashes and period. ```csharp // Flashes 5 times during the tween, with an alpha period of 0.2 transform.DOScale(big, 1f) .SetEase(Ease.Flash, overshootOrAmplitude: 5, period: 0.2f); /* - overshootOrAmplitude: Number of flashes. - period: Base alpha pulse length. The Flash ease outputs non-monotonic 0->1 curves, causing the position to oscillate around the endpoint. */ ``` ``` -------------------------------- ### Install AI Skills via UnitySkills Installer Source: https://github.com/besty0728/unity-skills/blob/main/docs/SETUP_GUIDE.md Use the UnitySkills Skill Installer within the Unity Editor to automatically install AI skills for supported tools. This copies necessary template files to the correct directory. ```bash Window → UnitySkills → Skill Installer ``` ```text SKILL.md # Main skill definition (AI reads this) skills/ # Per-module skill docs (38 functional + 14 advisory) scripts/unity_skills.py # Python client library scripts/agent_config.json # Agent configuration references/ # Unity development references ``` -------------------------------- ### Check Network Setup Source: https://github.com/besty0728/unity-skills/blob/main/SkillsForUnity/unity-skills~/skills/netcode/SKILL.md Inspect the current Unity Netcode setup. This is often the first step in diagnosing or verifying configuration. ```python u.call_skill("netcode_check_setup") ``` -------------------------------- ### Create agent_config.json for Manual Installation Source: https://github.com/besty0728/unity-skills/blob/main/README.md Create this JSON file in the `unity-skills/scripts/` directory during manual installation. Replace 'your-agent-name' with the actual AI tool's name. ```json { "agentId": "your-agent-name", "installedAt": "2026-02-11T00:00:00Z" } ``` -------------------------------- ### Start, Create, Add Component, and End Session Source: https://github.com/besty0728/unity-skills/blob/main/SkillsForUnity/unity-skills~/skills/workflow/SKILL.md Demonstrates starting a workflow session, creating a game object with a Rigidbody component, and then ending the session. This sequence is useful for grouping related operations that can be undone together. ```python unity_skills.call_skill("workflow_session_start", tag="Build Player") unity_skills.call_skill("gameobject_create", name="Player", primitiveType="Capsule") unity_skills.call_skill("component_add", name="Player", componentType="Rigidbody") unity_skills.call_skill("workflow_session_end") ``` -------------------------------- ### Get installed packages Source: https://context7.com/besty0728/unity-skills/llms.txt Retrieves information about the packages installed in the Unity project, including their versions. ```python result = unity_skills.call_skill("project_get_packages") ``` -------------------------------- ### UniTask.WhenAny Usage Example Source: https://github.com/besty0728/unity-skills/blob/main/SkillsForUnity/unity-skills~/skills/unitask-design/COMPOSITION.md Example demonstrating how to use UniTask.WhenAny to get the index and result of the first completed task, with a timeout fallback. ```csharp var (winIndex, result) = await UniTask.WhenAny( FetchFromServer(), UniTask.Delay(5000, cancellationToken: ct).ContinueWith(() => "timeout") ); ``` -------------------------------- ### Custom IFileSystem Implementation Example Source: https://github.com/besty0728/unity-skills/blob/main/SkillsForUnity/unity-skills~/skills/yooasset-design/FILESYSTEM.md Demonstrates how to build a custom `IFileSystem` by implementing the `IFileSystem` interface, exposing a `CreateFileSystemParameters(...)` static helper, and feeding the result into `CustomPlayModeParameters.FileSystemParameterList`. ```csharp // Samples~/Mini Game/Runtime/WechatFileSystem/WechatFileSystem.cs // Samples~/Mini Game/Runtime/TiktokFileSystem/TiktokFileSystem.cs // Samples~/Mini Game/Runtime/AlipayFileSystem/AlipayFileSystem.cs // Samples~/Mini Game/Runtime/TaptapFileSystem/TaptapFileSystem.cs // Samples~/Mini Game/Runtime/GooglePlayFileSystem/GooglePlayFileSystem.cs ``` -------------------------------- ### Specialized Package Installations Source: https://github.com/besty0728/unity-skills/blob/main/SkillsForUnity/unity-skills~/skills/package/SKILL.md APIs for quick setup of Cinemachine and Splines packages. ```APIDOC ## POST /package_install_cinemachine ### Description Install Cinemachine using the supported package/version strategy. ### Method POST ### Endpoint /package_install_cinemachine ### Parameters #### Request Body - **version** (integer) - Optional - `2` for CM2, `3` for CM3 ### Request Example ```json { "version": 3 } ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the operation was successful. - **status** (string) - The status of the job (optional). - **jobId** (string) - The ID of the asynchronous job (optional). - **message** (string) - A message describing the result. - **serverAvailability** (string) - The availability status of the server (optional). #### Response Example ```json { "success": true, "status": "completed", "message": "Cinemachine installed successfully.", "serverAvailability": "available" } ``` ## POST /package_install_splines ### Description Install or upgrade Unity Splines using the recommended version for the current Unity editor line. ### Method POST ### Endpoint /package_install_splines ### Parameters None. ### Request Example ```json {} ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the operation was successful. - **status** (string) - The status of the job (optional). - **jobId** (string) - The ID of the asynchronous job (optional). - **message** (string) - A message describing the result. - **serverAvailability** (string) - The availability status of the server (optional). #### Response Example ```json { "success": true, "status": "pending", "jobId": "job-xyz789", "message": "Splines installation job accepted.", "serverAvailability": "available" } ``` ``` -------------------------------- ### Get Asset Information by Location or GUID Source: https://github.com/besty0728/unity-skills/blob/main/SkillsForUnity/unity-skills~/skills/yooasset-design/LOADING.md Retrieve detailed information for a specific asset using its location string or unique GUID. An optional type parameter can be provided for more precise retrieval. ```csharp public AssetInfo GetAssetInfo(string location); public AssetInfo GetAssetInfo(string location, System.Type type); public AssetInfo GetAssetInfoByGUID(string assetGUID); public AssetInfo GetAssetInfoByGUID(string assetGUID, System.Type type); ``` -------------------------------- ### Start UnitySkills Server Source: https://github.com/besty0728/unity-skills/blob/main/docs/SETUP_GUIDE.md Initiate the UnitySkills REST server from the Unity Editor. Successful startup is indicated by a console message. ```bash Window → UnitySkills → Start Server ``` ```bash [UnitySkills] REST Server started at http://localhost:8090/ ``` -------------------------------- ### Efficient Material Setup with Batch Operations Source: https://github.com/besty0728/unity-skills/blob/main/SkillsForUnity/unity-skills~/skills/material/SKILL.md Demonstrates how to efficiently create, set colors, and assign materials using batch operations, reducing API calls compared to individual operations. ```python import unity_skills # BAD: 6 API calls unity_skills.call_skill("material_create", name="Mat1", savePath="Assets/Materials") unity_skills.call_skill("material_create", name="Mat2", savePath="Assets/Materials") unity_skills.call_skill("material_set_color", path="Assets/Materials/Mat1.mat", r=1, g=0, b=0) unity_skills.call_skill("material_set_color", path="Assets/Materials/Mat2.mat", r=0, g=0, b=1) unity_skills.call_skill("material_assign", name="Cube1", materialPath="Assets/Materials/Mat1.mat") unity_skills.call_skill("material_assign", name="Cube2", materialPath="Assets/Materials/Mat2.mat") # GOOD: 3 API calls unity_skills.call_skill("material_create_batch", items=[ {"name": "Mat1", "savePath": "Assets/Materials"}, {"name": "Mat2", "savePath": "Assets/Materials"} ]) unity_skills.call_skill("material_set_colors_batch", items=[ {"path": "Assets/Materials/Mat1.mat", "r": 1, "g": 0, "b": 0}, {"path": "Assets/Materials/Mat2.mat", "r": 0, "g": 0, "b": 1} ]) unity_skills.call_skill("material_assign_batch", items=[ {"name": "Cube1", "materialPath": "Assets/Materials/Mat1.mat"}, {"name": "Cube2", "materialPath": "Assets/Materials/Mat2.mat"} ]) ``` -------------------------------- ### Create and Configure Virtual Camera Source: https://github.com/besty0728/unity-skills/blob/main/SkillsForUnity/unity-skills~/skills/cinemachine/SKILL.md This example demonstrates creating a virtual camera and setting its follow and look-at targets. Ensure the 'Player' GameObject exists in the scene. ```python import unity_skills # Create a vcam that follows and looks at the player unity_skills.call_skill("cinemachine_create_vcam", name="PlayerCam") unity_skills.call_skill("cinemachine_set_targets", vcamName="PlayerCam", followName="Player", lookAtName="Player") ``` -------------------------------- ### Installation Check Source: https://github.com/besty0728/unity-skills/blob/main/SkillsForUnity/unity-skills~/skills/yooasset/SKILL.md Checks if the Unity Skills package is installed. ```APIDOC ## Check Installation ### Description Probes the installation status of the Unity Skills package. This works even if the package is missing. ### Method GET ### Endpoint `/yooasset_check_installed` ### Response #### Success Response (200) - **installed** (boolean) - Indicates if the package is installed. - **packageVersion** (string) - The installed version of the package. - **availablePipelines** (array) - A list of available pipelines. - **editorAvailable** (boolean) - Indicates if the package is available in the editor. ``` -------------------------------- ### Create Main Menu UI Source: https://github.com/besty0728/unity-skills/blob/main/SkillsForUnity/unity-skills~/skills/ui/SKILL.md This example demonstrates creating a main menu with a panel and buttons. It utilizes batch creation for buttons and then applies layout and anchoring rules for proper arrangement. ```python import unity_skills import json uniti_skills.call_skill("ui_create_canvas", name="MainMenu") unity_skills.call_skill("ui_create_panel", name="MenuPanel", parent="MainMenu", a=0.7) unity_skills.call_skill("ui_set_rect", name="MenuPanel", width=320, height=240) unity_skills.call_skill("ui_create_batch", items=json.dumps([ {"type": "Button", "name": "StartBtn", "parent": "MenuPanel", "text": "Start", "width": 220, "height": 44}, {"type": "Button", "name": "OptionsBtn", "parent": "MenuPanel", "text": "Options", "width": 220, "height": 44}, {"type": "Button", "name": "QuitBtn", "parent": "MenuPanel", "text": "Quit", "width": 220, "height": 44} ])) unity_skills.call_skill("ui_set_anchor", name="MenuPanel", preset="MiddleCenter") unity_skills.call_skill("ui_layout_children", name="MenuPanel", layoutType="Vertical", spacing=12) ``` -------------------------------- ### Package Installation and Removal Source: https://github.com/besty0728/unity-skills/blob/main/SkillsForUnity/unity-skills~/skills/package/SKILL.md Install, remove, or refresh Unity packages. ```APIDOC ## POST /package_install ### Description Install a package. Returns an async job when the request is accepted. ### Method POST ### Endpoint /package_install ### Parameters #### Request Body - **packageId** (string) - Required - Package ID to install - **version** (string) - Optional - Explicit version to install ### Request Example ```json { "packageId": "com.unity.new-package", "version": "1.0.0" } ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the operation was successful. - **status** (string) - The status of the job. - **jobId** (string) - The ID of the asynchronous job. - **message** (string) - A message describing the result. - **serverAvailability** (string) - The availability status of the server. #### Response Example ```json { "success": true, "status": "pending", "jobId": "job-12345", "message": "Package installation job accepted.", "serverAvailability": "available" } ``` ## POST /package_remove ### Description Remove an installed package. Returns an async job when the request is accepted. ### Method POST ### Endpoint /package_remove ### Parameters #### Request Body - **packageId** (string) - Required - Installed package ID to remove ### Request Example ```json { "packageId": "com.unity.old-package" } ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the operation was successful. - **status** (string) - The status of the job. - **jobId** (string) - The ID of the asynchronous job. - **message** (string) - A message describing the result. - **serverAvailability** (string) - The availability status of the server. #### Response Example ```json { "success": true, "status": "pending", "jobId": "job-67890", "message": "Package removal job accepted.", "serverAvailability": "available" } ``` ## POST /package_refresh ### Description Refresh the installed package cache used by query skills. ### Method POST ### Endpoint /package_refresh ### Parameters None. ### Response #### Success Response (200) - **success** (boolean) - Indicates if the operation was successful. - **status** (string) - The status of the job. - **jobId** (string) - The ID of the asynchronous job. - **message** (string) - A message describing the result. #### Response Example ```json { "success": true, "status": "pending", "jobId": "job-abcde", "message": "Package cache refresh job accepted." } ``` ``` -------------------------------- ### YooAsset Initialization and Package Creation Source: https://github.com/besty0728/unity-skills/blob/main/SkillsForUnity/unity-skills~/skills/yooasset-design/INIT.md Demonstrates the correct sequence for initializing YooAssets and creating a resource package. ```APIDOC ## YooAssets Initialization and Package Creation ### Description This section outlines the mandatory startup order for YooAssets and its resource packages. ### Startup Order 1. **Initialize YooAssets**: Call `YooAssets.Initialize()` once per process. This creates the driver GameObject and OperationSystem. 2. **Create Resource Package**: Use `YooAssets.CreatePackage("DefaultPackage")` to create a new package. 3. **Initialize Package**: Call `package.InitializeAsync()` and wait for its completion. The status must be `Succeed` before loading or updating assets. 4. **Update (Optional)**: Follow the update flow as described in UPDATE.md. 5. **Load Assets**: Use `package.LoadAssetAsync(location)` for individual assets. Remember to release the handle when done. ### Important Notes - `YooAssets.Initialize()` is idempotent; calling it multiple times will result in a warning and no further action. - Calls to package methods before `package.InitializeAsync` completes successfully will throw an exception in debug builds (guarded by `DebugCheckInitialize`). In release builds, this may result in silent NREs. ### Code Example ```csharp // Initialize YooAssets (once per process) if (!YooAssets.Initialized) YooAssets.Initialize(); // Create a default package var package = YooAssets.CreatePackage("DefaultPackage"); // Initialize the package asynchronously var initOp = package.InitializeAsync(new OfflinePlayModeParameters(hostServerURL)); yield return initOp; // Check if initialization was successful if (initOp.Status == EOperationStatus.Succeed) { // Proceed with loading assets var loadOp = package.LoadAssetAsync("MyAsset.prefab"); yield return loadOp; } ``` ``` -------------------------------- ### Correct Host Play Mode Setup Source: https://github.com/besty0728/unity-skills/blob/main/SkillsForUnity/unity-skills~/skills/yooasset-design/PLAYMODE.md For host-play scenarios, use `HostPlayModeParameters` and correctly configure both `BuildinFileSystemParameters` and `CacheFileSystemParameters`. ```csharp var p = new HostPlayModeParameters { BuildinFileSystemParameters = FileSystemParameters.CreateDefaultBuildinFileSystemParameters(), CacheFileSystemParameters = FileSystemParameters.CreateDefaultCacheFileSystemParameters(remoteServices), }; package.InitializeAsync(p); ``` -------------------------------- ### Get Scene Hierarchy API Source: https://github.com/besty0728/unity-skills/blob/main/SkillsForUnity/unity-skills~/skills/scene/SKILL.md API endpoint to get the hierarchy of the current Unity scene. ```APIDOC ## GET /api/unity/scene/hierarchy ### Description Retrieves the full hierarchy tree of the current Unity scene. ### Method GET ### Endpoint /api/unity/scene/hierarchy ### Parameters #### Query Parameters - **maxDepth** (integer) - Optional - Maximum depth of the hierarchy to retrieve. Defaults to 10. ### Response #### Success Response (200) - **success** (boolean) - Indicates if the operation was successful. - **hierarchy** (array) - An array representing the scene hierarchy. Each element contains: - **name** (string) - The name of the GameObject. - **instanceId** (integer) - The instance ID of the GameObject. - **children** (array) - An array of child GameObjects, recursively structured. #### Response Example { "success": true, "hierarchy": [ { "name": "GameObject1", "instanceId": 12345, "children": [ { "name": "Child1", "instanceId": 67890, "children": [] } ] } ] } ``` -------------------------------- ### Setup & Validation Skills Source: https://github.com/besty0728/unity-skills/blob/main/SkillsForUnity/unity-skills~/skills/netcode/SKILL.md Skills for checking the Netcode setup, creating and configuring the NetworkManager, retrieving its information, and removing it. ```APIDOC ## Setup & Validation Skills ### Description Skills for checking the Netcode setup, creating and configuring the NetworkManager, retrieving its information, and removing it. ### Skills #### `netcode_check_setup` ##### Description Verify package, NetworkManager, Transport, PlayerPrefab, and PrefabsList consistency. ##### Parameters - `verbose` (boolean) - Optional - If true, provides more detailed output. #### `netcode_create_manager` ##### Description Create NetworkManager and UnityTransport. ##### Parameters - `name` (string) - Optional - The name for the NetworkManager. #### `netcode_configure_manager` ##### Description Bulk-edit NetworkConfig settings such as TickRate, ConnectionApproval, EnableSceneManagement, NetworkTopology, and more. ##### Parameters - `name` (string) - Optional - The name of the NetworkManager to configure. - Additional optional parameters for NetworkConfig fields (e.g., `tickRate`, `connectionApproval`, `enableSceneManagement`, `networkTopology`). #### `netcode_get_manager_info` ##### Description Read NetworkConfig and runtime state of the NetworkManager. ##### Parameters - `name` (string) - Optional - The name of the NetworkManager to query. #### `netcode_remove_manager` ##### Description Delete the NetworkManager. The NetworkManager must be shut down before removal. ##### Parameters - `name` (string) - Optional - The name of the NetworkManager to remove. ``` -------------------------------- ### Universal RPC Examples Source: https://github.com/besty0728/unity-skills/blob/main/SkillsForUnity/unity-skills~/skills/netcode-design/RPC.md Demonstrates the recommended universal RPC model using the `[Rpc]` attribute with different `SendTo` targets. This model offers flexibility and does not require specific method name suffixes. ```csharp [Rpc(SendTo.Server)] void AttackServerRpc(int targetId) { ... } ``` ```csharp [Rpc(SendTo.NotServer)] void ShowDamageRpc(int damage) { ... } ``` ```csharp [Rpc(SendTo.Owner)] void GrantLootRpc(int itemId) { ... } ``` ```csharp [Rpc(SendTo.SpecifiedInParams)] void TellClientRpc(int msg, RpcParams p = default) { ... } ``` -------------------------------- ### Start Network Client Source: https://github.com/besty0728/unity-skills/blob/main/SkillsForUnity/unity-skills~/skills/netcode/SKILL.md Initiate the network session as a client. This skill requires the editor to be in PlayMode. ```python u.call_skill("netcode_start_client") ``` -------------------------------- ### Use Standard Network Attributes and Methods Source: https://github.com/besty0728/unity-skills/blob/main/SkillsForUnity/unity-skills~/skills/netcode-design/PITFALLS.md Adhere to the provided network attributes and methods. Use `[Rpc]`, `[ServerRpc]`, `[ClientRpc]`, `Instantiate` + `.Spawn()`, or `InstantiateAndSpawn` instead of inventing non-existent ones. ```csharp Instantiate() + .Spawn() ``` ```csharp InstantiateAndSpawn() ``` -------------------------------- ### DOPath Start Position Handling Source: https://github.com/besty0728/unity-skills/blob/main/SkillsForUnity/unity-skills~/skills/dotween-design/PITFALLS.md When using `DOPath`, the tween starts at the object's current position and moves towards the first waypoint. If the waypoints array does not include the object's starting position, the tween will appear to jump to the first waypoint. ```csharp // ❌ Waypoints don't include start position — tween jumps to first waypoint transform.position = Vector3.zero; transform.DOPath(new[] { Vector3.right * 5, Vector3.right * 10 }, 2f); // Jumps to (5,0,0) on frame 1. ``` ```csharp // ✅ Include start position or use relative transform.DOPath(new[] { transform.position, // start here Vector3.right * 5, Vector3.right * 10 }, 2f); ``` -------------------------------- ### Basic XR Rig Setup Source: https://github.com/besty0728/unity-skills/blob/main/SkillsForUnity/unity-skills~/skills/xr/SKILL.md Initializes a basic XR rig with essential components like controllers, interactors, and locomotion providers. Ensure the XR Interaction Manager is present in the scene. ```python import unity_skills as u u.call_skill("xr_check_setup") u.call_skill("xr_setup_rig", name="XR Origin") u.call_skill("xr_add_ray_interactor", name="Right Controller") u.call_skill("xr_add_direct_interactor", name="Left Controller") u.call_skill("xr_setup_teleportation") u.call_skill("xr_setup_turn_provider", turnType="Snap", turnAmount=45) u.call_skill("xr_add_grab_interactable", name="MyCube", movementType="VelocityTracking") ``` -------------------------------- ### Create Spotlight Source: https://context7.com/besty0728/unity-skills/llms.txt Use 'light_create' with 'Spot' type to create a spotlight. Configure position, intensity, range, angle, and shadow type. ```python result = unity_skills.call_skill("light_create", name="Spotlight", lightType="Spot", x=0, y=5, z=0, intensity=3, range=15, spotAngle=45, shadows="hard" ) ``` -------------------------------- ### Workflow Task Start Source: https://context7.com/besty0728/unity-skills/llms.txt Starts a new workflow task for grouped undo/redo operations. Provide a tag and description for the task. ```python result = unity_skills.call_skill("workflow_task_start", tag="create_player", description="Create player with components" ) ``` -------------------------------- ### Check YooAsset Installation Source: https://github.com/besty0728/unity-skills/blob/main/SkillsForUnity/unity-skills~/skills/yooasset/SKILL.md Probes the YooAsset installation status, including version and available pipelines. Works even if the package is missing. ```python import unity_skills as u u.call_skill("yooasset_check_installed") ``` -------------------------------- ### Correct Pattern for Instantiating from Successful Handle Source: https://github.com/besty0728/unity-skills/blob/main/SkillsForUnity/unity-skills~/skills/yooasset-design/HANDLES.md Demonstrates the correct procedure for instantiating an asset from a handle, including a check for successful loading before attempting instantiation. ```csharp // ✅ CORRECT if (h.Status == EOperationStatus.Succeed) { var go = h.InstantiateSync(); } else { Debug.LogWarning(h.LastError); } ``` -------------------------------- ### Create a Command File to Set Environment Variables Source: https://github.com/besty0728/unity-skills/blob/main/SkillsForUnity/unity-skills~/references/xr.md This guide explains how to create a command file (.cmd) to set environment variables and launch applications. This is often used for configuring build environments. ```batch @echo off REM Set environment variables SET UNITY_PATH=C:\Program Files\Unity\Hub\Editor\2022.3.10f1\Editor\Unity.exe SET PROJECT_PATH=D:\MyUnityProject REM Change directory to the project cd /d %PROJECT_PATH% REM Launch Unity with specific arguments (e.g., build) start "Unity Build" "%UNITY_PATH%" -batchmode -quit -projectPath "%PROJECT_PATH%" -buildTarget StandaloneWindows64 -executeMethod BuildScript.PerformBuild ECHO Build process initiated. ``` -------------------------------- ### REST API Get All Skills Source: https://github.com/besty0728/unity-skills/blob/main/docs/SETUP_GUIDE.md Retrieve a list of all available skills from the UnitySkills server via a direct HTTP GET request. ```bash curl http://localhost:8090/skills ``` -------------------------------- ### Efficient Menu Example Source: https://github.com/besty0728/unity-skills/blob/main/SkillsForUnity/unity-skills~/skills/ui/UI_REFERENCE.md Demonstrates a streamlined workflow for creating a menu with buttons using various UI skills. ```APIDOC ## Efficient Menu Example This example showcases how to create a canvas, a panel, and several buttons within that panel, then apply a vertical layout. ### Method `unity_skills.call_skill` is used to invoke various UI creation and manipulation functions. ### Endpoints - `ui_create_canvas` - `ui_create_panel` - `ui_set_rect` - `ui_create_batch` - `ui_layout_children` ### Parameters **`ui_create_canvas`** - `name` (string) - Required - The name for the new Canvas. **`ui_create_panel`** - `name` (string) - Required - The name for the new Panel. - `parent` (string) - Optional - The name of the parent object. - `a` (float) - Optional - Alpha transparency value (0.0 to 1.0). **`ui_set_rect`** - `name` (string) - Required - The name of the UI element to set the rectangle for. - `width` (int) - Required - The desired width. - `height` (int) - Required - The desired height. **`ui_create_batch`** - `items` (string) - Required - A JSON string representing an array of UI elements to create. Each element can have: - `type` (string) - Required - The type of UI element (e.g., "Button", "Image"). - `name` (string) - Required - The name of the UI element. - `parent` (string) - Optional - The name of the parent object. - `text` (string) - Optional - Text to display on the element (for Button, Text). - `width` (int) - Optional - The desired width. - `height` (int) - Optional - The desired height. **`ui_layout_children`** - `name` (string) - Required - The name of the parent object whose children will be laid out. - `layoutType` (string) - Required - The type of layout ('Vertical', 'Horizontal', 'Grid'). - `spacing` (int) - Optional - The spacing between child elements. ### Request Example ```python import unity_skills import json unity_skills.call_skill("ui_create_canvas", name="MainMenu") unity_skills.call_skill("ui_create_panel", name="MenuPanel", parent="MainMenu", a=0.65) unity_skills.call_skill("ui_set_rect", name="MenuPanel", width=300, height=200) unity_skills.call_skill("ui_create_batch", items=json.dumps([ {"type": "Button", "name": "StartBtn", "parent": "MenuPanel", "text": "Start", "width": 220, "height": 44}, {"type": "Button", "name": "OptionsBtn", "parent": "MenuPanel", "text": "Options", "width": 220, "height": 44}, {"type": "Button", "name": "QuitBtn", "parent": "MenuPanel", "text": "Quit", "width": 220, "height": 44} ])) unity_skills.call_skill("ui_layout_children", name="MenuPanel", layoutType="Vertical", spacing=12) ``` ### Response Successful execution of these skills typically results in the creation of UI elements in the Unity scene. Specific return values are not detailed in this reference. ``` -------------------------------- ### Get CancellationTokenOnDestroy for MonoBehaviour Source: https://github.com/besty0728/unity-skills/blob/main/SkillsForUnity/unity-skills~/skills/unitask-design/CANCELLATION.md Get a CancellationToken that is canceled when the associated MonoBehaviour is destroyed. This extension method attaches a hidden AsyncDestroyTrigger component. ```csharp public static CancellationToken GetCancellationTokenOnDestroy(this MonoBehaviour monoBehaviour); public static CancellationToken GetCancellationTokenOnDestroy(this GameObject gameObject); public static CancellationToken GetCancellationTokenOnDestroy(this Component component); ``` ```csharp public class Enemy : MonoBehaviour { async UniTaskVoid Start() { // Token is canceled when this GameObject is destroyed var ct = this.GetCancellationTokenOnDestroy(); await RoamAsync(ct); } } ``` -------------------------------- ### UniTask.Timeout Usage Example Source: https://github.com/besty0728/unity-skills/blob/main/SkillsForUnity/unity-skills~/skills/unitask-design/COMPOSITION.md Example of using the .Timeout extension method to throw a TimeoutException if a UniTask does not complete within a specified duration. ```csharp // Throws TimeoutException if > 5s var result = await LongWork().Timeout(TimeSpan.FromSeconds(5)); ``` -------------------------------- ### Handle NetworkManager Start Failures Source: https://github.com/besty0728/unity-skills/blob/main/SkillsForUnity/unity-skills~/skills/netcode-design/PITFALLS.md Always check the boolean return value of `StartHost`, `StartServer`, and `StartClient` to handle potential startup failures gracefully. ```csharp if (!NetworkManager.Singleton.StartHost()) { ...handle failure... } ``` -------------------------------- ### UniTask.TimeoutWithoutException Usage Example Source: https://github.com/besty0728/unity-skills/blob/main/SkillsForUnity/unity-skills~/skills/unitask-design/COMPOSITION.md Example of using the .TimeoutWithoutException extension method, which returns a boolean indicating if a timeout occurred instead of throwing an exception. ```csharp // Non-throwing variant var (isTimeout, result) = await LongWork().TimeoutWithoutException(TimeSpan.FromSeconds(5)); ``` -------------------------------- ### Example Workflow: Clean Project Source: https://github.com/besty0728/unity-skills/blob/main/SkillsForUnity/unity-skills~/skills/cleaner/SKILL.md Demonstrates a workflow for cleaning a Unity project by finding and fixing issues, identifying duplicates, and previewing deletions. ```APIDOC ## Example Workflow: Clean Project ### Description This workflow demonstrates a sequence of calls to various Unity skills to clean and analyze a project. ### Code Example ```python import unity_skills # 1. Find all missing references and fix them missing = unity_skills.call_skill("cleaner_find_missing_references") for issue in missing['issues']: if issue['type'] == 'MissingScript': print(f"⚠️ Missing script on: {issue['path']}") # 2. Find duplicate textures dupes = unity_skills.call_skill("cleaner_find_duplicates", assetType="Texture2D") if dupes['totalWastedMB'] > 10: print(f"🗑️ {dupes['totalWastedMB']:.1f} MB wasted on duplicates") # 3. Find unused materials unused = unity_skills.call_skill("cleaner_find_unused_assets", assetType="Material") print(f"📦 {unused['potentiallyUnusedCount']} potentially unused materials") # 4. Preview cleanup paths_to_delete = [a['path'] for a in unused['assets'][:5]] preview = unity_skills.call_skill("cleaner_delete_assets", paths=paths_to_delete, dryRun=True) print(f"Would free: {preview['totalMB']:.2f} MB") ``` ``` -------------------------------- ### Subscribe to OnLoadComplete in Start Source: https://github.com/besty0728/unity-skills/blob/main/SkillsForUnity/unity-skills~/skills/netcode-design/SCENE.md Subscribe to the OnLoadComplete event within the Start method. Be aware of the potential for a NullReferenceException if NetworkManager.SceneManager is accessed before it's initialized. ```csharp // ⚠ NetworkManager.SceneManager can be null before StartHost/Server void Start() { NetworkManager.SceneManager.OnLoadComplete += OnSceneLoaded; // NRE risk } ``` -------------------------------- ### Start Network Host Source: https://github.com/besty0728/unity-skills/blob/main/SkillsForUnity/unity-skills~/skills/netcode/SKILL.md Initiate the network session as a host. This skill requires the editor to be in PlayMode. ```python u.call_skill("netcode_start_host") ``` -------------------------------- ### Default-Package Static Shortcuts Source: https://github.com/besty0728/unity-skills/blob/main/SkillsForUnity/unity-skills~/skills/yooasset-design/LOADING.md Demonstrates how to use static shortcuts for loading assets via the default package. ```APIDOC ## Default-Package Static Shortcuts ### Description Illustrates the usage of static shortcuts provided by `YooAssetsExtension` for accessing the default `ResourcePackage`. These shortcuts are available from YooAsset version 2.3.18 onwards. ### Setting the Default Package ```csharp YooAssets.SetDefaultPackage(package); ``` ### Usage Examples ```csharp // Load asynchronously AssetHandle h1 = YooAssets.LoadAssetAsync("player"); // Load synchronously with type specified AssetHandle h2 = YooAssets.LoadAssetSync("ui/icon", typeof(Sprite)); ``` ### Important Note While convenient, these shortcuts can obscure package ownership. For projects with multiple packages, or for libraries and tests, it is recommended to explicitly reference the `ResourcePackage` instance: ```csharp var package = YooAssets.GetPackage("DefaultPackage"); var h = package.LoadAssetAsync("player"); ``` ``` -------------------------------- ### Example Workflow: Clean Project Source: https://github.com/besty0728/unity-skills/blob/main/SkillsForUnity/unity-skills~/skills/cleaner/SKILL.md A comprehensive workflow demonstrating how to find and fix missing references, identify duplicate textures, locate unused materials, and preview asset deletion. ```python import unity_skills # 1. Find all missing references and fix them missing = unity_skills.call_skill("cleaner_find_missing_references") for issue in missing['issues']: if issue['type'] == 'MissingScript': print(f"⚠️ Missing script on: {issue['path']}") # 2. Find duplicate textures dupes = unity_skills.call_skill("cleaner_find_duplicates", assetType="Texture2D") if dupes['totalWastedMB'] > 10: print(f"🗑️ {dupes['totalWastedMB']:.1f} MB wasted on duplicates") # 3. Find unused materials unused = unity_skills.call_skill("cleaner_find_unused_assets", assetType="Material") print(f"📦 {unused['potentiallyUnusedCount']} potentially unused materials") # 4. Preview cleanup paths_to_delete = [a['path'] for a in unused['assets'][:5]] preview = unity_skills.call_skill("cleaner_delete_assets", paths=paths_to_delete, dryRun=True) print(f"Would free: {preview['totalMB']:.2f} MB") ``` -------------------------------- ### Get Unity scene hierarchy Source: https://github.com/besty0728/unity-skills/blob/main/SkillsForUnity/unity-skills~/skills/scene/SKILL.md Use `scene_get_hierarchy` to get the full scene hierarchy tree. You can limit the depth of the hierarchy returned using the `maxDepth` parameter. ```python hierarchy = unity_skills.call_skill("scene_get_hierarchy", maxDepth=5) ``` -------------------------------- ### Install Unity Plugin - Beta Version Source: https://github.com/besty0728/unity-skills/blob/main/README.md Use this Git URL in Unity Package Manager for the beta version of the Unity Skills plugin. ```git https://github.com/Besty0728/Unity-Skills.git?path=/SkillsForUnity#beta ``` -------------------------------- ### LoadAssetsAsync with MergeMode Example Source: https://github.com/besty0728/unity-skills/blob/main/SkillsForUnity/unity-skills~/skills/addressables-design/LOADING.md Loads multiple assets using a list of keys and specifies how to merge the results. This example loads sprites with both 'UI' and 'Icon' labels. ```csharp LoadAssetsAsync(new[] {"UI", "Icon"}, null, MergeMode.Intersection) ``` -------------------------------- ### Custom IFileSystem Implementation Source: https://github.com/besty0728/unity-skills/blob/main/SkillsForUnity/unity-skills~/skills/yooasset-design/FILESYSTEM.md Guidance on creating and integrating custom file system implementations within the Unity Skills project. ```APIDOC ## Custom File System Implementation ### Overview Custom file systems can be integrated by implementing the `IFileSystem` interface and providing a factory helper. The `FileSystemParameters` class delegates creation to `Type.GetType(FileSystemClass)`, sets parameters using `IFileSystem.SetParameter`, and finalizes with `OnCreate`. ### Steps to Build a Custom File System 1. **Implement `IFileSystem`**: Ensure all required members of the interface (defined in `Runtime/FileSystem/`) are implemented. 2. **Expose `CreateFileSystemParameters(...)`**: Create a static helper method that mirrors the built-in factory methods. 3. **Integrate**: Feed the result of your factory helper into `CustomPlayModeParameters.FileSystemParameterList`. The last element in this list is considered the main file system. ### Example Integrations - `Samples~/Mini Game/Runtime/WechatFileSystem/WechatFileSystem.cs` - `Samples~/Mini Game/Runtime/TiktokFileSystem/TiktokFileSystem.cs` - `Samples~/Mini Game/Runtime/AlipayFileSystem/AlipayFileSystem.cs` - `Samples~/Mini Game/Runtime/TaptapFileSystem/TaptapFileSystem.cs` - `Samples~/Mini Game/Runtime/GooglePlayFileSystem/GooglePlayFileSystem.cs` ### Source `FileSystemParameters.cs:42-67` ```