A game about forced loneliness, made by TACStudios
1# Add documentation to a Custom C# node 2 3You can also add [Graph Inspector](vs-interface-overview.md#the-graph-inspector) documentation to a Custom C# node. Visual Scripting displays the documentation in the Graph Inspector when you select a node in a Script Graph. The documentation isn't required to use the node, but can help your users understand the purpose and usage of a node. 4 5To add documentation to a node: 6 71. [!include[open-project-window](./snippets/vs-open-project-window.md)] 8 9 > [!NOTE] 10 > If you already have an **Editor** folder in your project, you can skip Steps 2-3. 11 122. Right-click your **Assets** folder or select **Add** (+), then select **Folder**. 13 141. Name the folder **Editor**. 15 163. Do one of the following: 17 18 - Right-click your **Editor** folder in the Project window's folder list. 19 - Right-click anywhere in the Project window's preview pane with your **Editor** folder selected. 20 214. [!include[create-c-script](./snippets/vs-create-c-script-project.md)] 22 235. Enter a name, such as `MyNodeDescriptor` for the new script file. 24 251. Press Enter. 26 276. [!include[open-new-external-code](./snippets/vs-open-new-external-code.md)] 28 297. In your external editor, copy and paste the following code into the C# script: 30 31 ```C# 32 using System; 33 using Unity.VisualScripting; 34 using UnityEngine; 35 36 [Descriptor(typeof(MyNode))] 37 public class MyNodeDescriptor : UnitDescriptor<MyNode> 38 { 39 public MyNodeDescriptor(MyNode unit) : base(unit) {} 40 41 protected override void DefinedPort(IUnitPort port, UnitPortDescription description) 42 { 43 base.DefinedPort(port, description); 44 switch (port.key) 45 { 46 case "inputTrigger": 47 description.summary = "Trigger the concatenation of two strings, myValueA and myValueB, and return the result string on the Result port."; 48 break; 49 case "myValueA": 50 description.summary = "First string value."; 51 break; 52 case "myValueB": 53 description.summary = "Second string value."; 54 break; 55 case "outputTrigger": 56 description.summary = "Execute the next action in the Script Graph after concatenating myValueA and myValueB."; 57 break; 58 case "result": 59 description.summary = "The result string obtained from concatenating myValueA and myValueB."; 60 break; 61 } 62 } 63 } 64 ``` 65 You can modify the script to suit the specifics of your own node.<br/> 66 678. [!include[save-script](./snippets/vs-save-script.md)] 68 691. [!include[return-unity](./snippets/vs-return-unity.md)] 70 719. Do one of the following: 72 73 - [!include[open-graph-w-node](./snippets/custom-c-nodes/vs-open-graph-w-node.md)]. 74 - [!include[ff-add-node](./snippets/custom-c-nodes/vs-ff-add-node.md)] 75 7610. Select the node and open the [Graph Inspector](vs-interface-overview.md#the-graph-inspector) to view your documentation. 77 78 ![An image of the Graph window. The Graph Inspector is open on the left with the Custom C# node, My Node, selected. The Graph Inspector displays the documentation written for each port on the node, underneath the name and type for each port.](images/vs-my-node-custom-node-descriptions-inspector.png) 79 80## Next steps 81 82After you add documentation to a node, you can choose to further customize the node with [node class and port attributes](vs-create-custom-node-attributes-reference.md).