Documentation

Unity Engine

Download Unity

Unity Engine

Create scripts

Create C# script assets from the Editor to add custom functionality to your application.
Read time 1 minuteLast updated 3 days ago

Scripts let you customize and extend the capabilities of your application with C# code.
Create scripts that derive from Unity's built-in
MonoBehaviour
class to control the behavior of GameObjects with components. Create scripts that derive from
ScriptableObject
to store large amounts of data efficiently in your application. Alternatively, you can start with an empty C# script to develop your own non-Unity classes.
Unlike most other assets, you usually create scripts directly within the Unity Editor.

Create a script asset

To create a script:
  1. In the Project window, select the folder where you want to create the script.
  2. Navigate to the Scripting menu in one of the following ways:
    • From the main menu, go to Assets > Create > Scripting.
    • In the Project window toolbar, select Create (+) > Scripting.
  3. Select the type of script you want to create.
  4. Enter a name for the script. For more information about how to name your scripts, refer to Script file names and namespaces.
Unity creates the script asset and compiles it. To edit the script, double-click it in the Project window to open it in your external script editor. To use a
MonoBehaviour
script as a component, attach it to a GameObject.

Additional resources