Creating Custom Components and Scripts

Creating a Custom Component / Script Through the Inspector

Sometimes, you have to make your own component. These are called Scripts and use C# and Unity's libraries and classes. These built-in libraries and classes allow you to use very little script compared to coding everything by scratch.

To add a custom component through the Inspector, click the Add Component button.

Scroll down to New script.

This will ask you for the name of your script and will let you know if it matches the name of an existing script."

Type in the name of your script and you are absolutely sure that's what you want to name it, click the Create and Add button.

The script will now appear in the Project window, in the Assets folder, the list of components, and in the Inspector.

The script can now be edited in the IDE/code editor set up with Unity (usually Visual Studio or MonoDevelop).

Please see the Coding Basics section for more information on the actual scripting.

Creating a Script Through the Project Tab

Add a C# Script using the Assets > Create menu or right-clicking in the Project window.

This will create a script asset within the current folder with the name highlighted ready to change.

Press the ENTER key to confirm the name.

The script can now be edited in the IDE/code editor set up with Unity (usually Visual Studio or MonoDevelop).

After editing, the script will need to be added to the game object or asset for it to run.

Please see the Coding Basics section for more information on the actual scripting.

Updating ComponentsDeleting Components and Scripts

Last updated

Was this helpful?