Version: Unity 6.0 (6000.0)
Language : English
Script file names and namespaces
Scripts in the Inspector window

Create scripts

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 componentsA functional part of a GameObject. A GameObject can contain any number of components. Unity has many built-in components, and you can create your own by writing scripts that inherit from MonoBehaviour. More info
See in Glossary
. 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 windowA window that shows the contents of your Assets folder (Project tab) More info
      See in Glossary
      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

Script file names and namespaces
Scripts in the Inspector window