A game about forced loneliness, made by TACStudios
1# Refactor a C# script with Visual Scripting
2
3Visual Scripting creates nodes from methods, fields, and properties from C# script in your project. Visual Scripting creates these nodes after you [regenerate your Node Library](vs-configuration.md) and [add any relevant types to your Type Options](vs-add-remove-type-options.md).
4
5For example, Visual Scripting created the following Take Damage node from a custom C# script that defines the `Player` class.
6
7
8
9Visual Scripting generated the node with the following code, which creates a `Player` class with a `TakeDamage` member.
10
11``` C#
12 using UnityEngine;
13
14 public class Player : MonoBehaviour
15 {
16 public void TakeDamage(int damage)
17 {
18 //...
19 }
20 }
21```
22
23> [!TIP]
24> You can [create your own custom node](vs-create-custom-node.md) or [create a custom event](vs-custom-events.md) to customize the ports and information displayed on your nodes.
25
26If you change the name of the `TakeDamage` member in the C# script, Visual Scripting displays an error in Script Graphs that use the Take Damage node.
27
28
29
30To rename a member, type, class, struct, enum, or other API element that a Visual Scripting node uses in a project, add the `[RenamedFrom]` attribute to the relevant API element in the script file. To avoid issues with Unity's serialization, the `[RenamedFrom]` attribute tells Visual Scripting that an API or one of its elements has been renamed.
31
32For more information on how to add the `[RenamedFrom]` attribute to a C# script, see [Add the RenamedFrom attribute to a C# script](vs-refactor-add-attribute.md).
33
34## Additional resources
35
36- [Add the RenamedFrom attribute to a C# script](vs-refactor-add-attribute.md)
37- [Configure project settings](vs-configuration.md)
38- [Add or remove types from your Type Options](vs-add-remove-type-options.md)
39- [Custom C# nodes](vs-create-custom-node.md)
40- [Custom events](vs-custom-events.md)